4
4
import io .goodforgod .api .etherscan .error .EtherScanResponseException ;
5
5
import io .goodforgod .api .etherscan .http .EthHttpClient ;
6
6
import io .goodforgod .api .etherscan .manager .RequestQueueManager ;
7
+ import io .goodforgod .api .etherscan .model .EthSupply ;
7
8
import io .goodforgod .api .etherscan .model .Price ;
8
- import io .goodforgod .api .etherscan .model .Supply ;
9
+ import io .goodforgod .api .etherscan .model .Wei ;
10
+ import io .goodforgod .api .etherscan .model .response .EthSupplyResponseTO ;
9
11
import io .goodforgod .api .etherscan .model .response .PriceResponseTO ;
10
12
import io .goodforgod .api .etherscan .model .response .StringResponseTO ;
11
13
import io .goodforgod .api .etherscan .util .BasicUtils ;
22
24
final class StatisticAPIProvider extends BasicProvider implements StatisticAPI {
23
25
24
26
private static final String ACT_SUPPLY_PARAM = ACT_PREFIX + "ethsupply" ;
27
+ private static final String ACT_SUPPLY2_PARAM = ACT_PREFIX + "ethsupply2" ;
25
28
private static final String ACT_TOKEN_SUPPLY_PARAM = ACT_PREFIX + "tokensupply" ;
26
29
private static final String ACT_LASTPRICE_PARAM = ACT_PREFIX + "ethprice" ;
27
30
@@ -36,30 +39,39 @@ final class StatisticAPIProvider extends BasicProvider implements StatisticAPI {
36
39
37
40
@ NotNull
38
41
@ Override
39
- public Supply supply () throws EtherScanException {
42
+ public Wei supply () throws EtherScanException {
40
43
final StringResponseTO response = getRequest (ACT_SUPPLY_PARAM , StringResponseTO .class );
41
44
if (response .getStatus () != 1 )
42
45
throw new EtherScanResponseException (response );
43
46
44
- return new Supply (new BigInteger (response .getResult ()));
47
+ return Wei .ofWei (new BigInteger (response .getResult ()));
48
+ }
49
+
50
+ @ Override
51
+ public @ NotNull EthSupply supplyTotal () throws EtherScanException {
52
+ final EthSupplyResponseTO response = getRequest (ACT_SUPPLY2_PARAM , EthSupplyResponseTO .class );
53
+ if (response .getStatus () != 1 )
54
+ throw new EtherScanResponseException (response );
55
+
56
+ return response .getResult ();
45
57
}
46
58
47
59
@ NotNull
48
60
@ Override
49
- public BigInteger supply (String contract ) throws EtherScanException {
61
+ public Wei supply (String contract ) throws EtherScanException {
50
62
BasicUtils .validateAddress (contract );
51
63
52
64
final String urlParams = ACT_TOKEN_SUPPLY_PARAM + CONTRACT_ADDRESS_PARAM + contract ;
53
65
final StringResponseTO response = getRequest (urlParams , StringResponseTO .class );
54
66
if (response .getStatus () != 1 )
55
67
throw new EtherScanResponseException (response );
56
68
57
- return new BigInteger (response .getResult ());
69
+ return Wei . ofWei ( new BigInteger (response .getResult () ));
58
70
}
59
71
60
72
@ NotNull
61
73
@ Override
62
- public Price lastPrice () throws EtherScanException {
74
+ public Price priceLast () throws EtherScanException {
63
75
final PriceResponseTO response = getRequest (ACT_LASTPRICE_PARAM , PriceResponseTO .class );
64
76
if (response .getStatus () != 1 )
65
77
throw new EtherScanResponseException (response );
0 commit comments