44import io .goodforgod .api .etherscan .error .EtherScanResponseException ;
55import io .goodforgod .api .etherscan .http .EthHttpClient ;
66import io .goodforgod .api .etherscan .manager .RequestQueueManager ;
7+ import io .goodforgod .api .etherscan .model .EthSupply ;
78import 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 ;
911import io .goodforgod .api .etherscan .model .response .PriceResponseTO ;
1012import io .goodforgod .api .etherscan .model .response .StringResponseTO ;
1113import io .goodforgod .api .etherscan .util .BasicUtils ;
2224final class StatisticAPIProvider extends BasicProvider implements StatisticAPI {
2325
2426 private static final String ACT_SUPPLY_PARAM = ACT_PREFIX + "ethsupply" ;
27+ private static final String ACT_SUPPLY2_PARAM = ACT_PREFIX + "ethsupply2" ;
2528 private static final String ACT_TOKEN_SUPPLY_PARAM = ACT_PREFIX + "tokensupply" ;
2629 private static final String ACT_LASTPRICE_PARAM = ACT_PREFIX + "ethprice" ;
2730
@@ -36,30 +39,39 @@ final class StatisticAPIProvider extends BasicProvider implements StatisticAPI {
3639
3740 @ NotNull
3841 @ Override
39- public Supply supply () throws EtherScanException {
42+ public Wei supply () throws EtherScanException {
4043 final StringResponseTO response = getRequest (ACT_SUPPLY_PARAM , StringResponseTO .class );
4144 if (response .getStatus () != 1 )
4245 throw new EtherScanResponseException (response );
4346
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 ();
4557 }
4658
4759 @ NotNull
4860 @ Override
49- public BigInteger supply (String contract ) throws EtherScanException {
61+ public Wei supply (String contract ) throws EtherScanException {
5062 BasicUtils .validateAddress (contract );
5163
5264 final String urlParams = ACT_TOKEN_SUPPLY_PARAM + CONTRACT_ADDRESS_PARAM + contract ;
5365 final StringResponseTO response = getRequest (urlParams , StringResponseTO .class );
5466 if (response .getStatus () != 1 )
5567 throw new EtherScanResponseException (response );
5668
57- return new BigInteger (response .getResult ());
69+ return Wei . ofWei ( new BigInteger (response .getResult () ));
5870 }
5971
6072 @ NotNull
6173 @ Override
62- public Price lastPrice () throws EtherScanException {
74+ public Price priceLast () throws EtherScanException {
6375 final PriceResponseTO response = getRequest (ACT_LASTPRICE_PARAM , PriceResponseTO .class );
6476 if (response .getStatus () != 1 )
6577 throw new EtherScanResponseException (response );
0 commit comments