Skip to content

Commit 47e04a8

Browse files
committed
[2.0.0-SNAPSHOT]
EthSupply for StatisticAPI#supplyTotal added Javadoc fixed
1 parent 25751ab commit 47e04a8

21 files changed

+250
-73
lines changed

src/main/java/io/goodforgod/api/etherscan/AccountAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.jetbrains.annotations.NotNull;
77

88
/**
9-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#accounts">...</a>
9+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/accounts">...</a>
1010
*
1111
* @author GoodforGod
1212
* @since 28.10.2018

src/main/java/io/goodforgod/api/etherscan/AccountAPIProvider.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public Balance balance(String address) throws EtherScanException {
6464
if (response.getStatus() != 1)
6565
throw new EtherScanResponseException(response);
6666

67-
return new Balance(address, new Wei(new BigInteger(response.getResult())));
67+
return new Balance(address, Wei.ofWei(new BigInteger(response.getResult())));
6868
}
6969

7070
@NotNull
@@ -78,7 +78,7 @@ public TokenBalance balance(String address, String contract) throws EtherScanExc
7878
if (response.getStatus() != 1)
7979
throw new EtherScanResponseException(response);
8080

81-
return new TokenBalance(address, new Wei(new BigInteger(response.getResult())), contract);
81+
return new TokenBalance(address, Wei.ofWei(new BigInteger(response.getResult())), contract);
8282
}
8383

8484
@NotNull
@@ -101,7 +101,7 @@ public List<Balance> balances(List<String> addresses) throws EtherScanException
101101

102102
if (!BasicUtils.isEmpty(response.getResult()))
103103
balances.addAll(response.getResult().stream()
104-
.map(r -> new Balance(r.getAccount(), new Wei(new BigInteger(r.getBalance()))))
104+
.map(r -> new Balance(r.getAccount(), Wei.ofWei(new BigInteger(r.getBalance()))))
105105
.collect(Collectors.toList()));
106106
}
107107

src/main/java/io/goodforgod/api/etherscan/BlockAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.jetbrains.annotations.NotNull;
77

88
/**
9-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#blocks">...</a>
9+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/blocks">...</a>
1010
*
1111
* @author GoodforGod
1212
* @since 30.10.2018

src/main/java/io/goodforgod/api/etherscan/ContractAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import org.jetbrains.annotations.NotNull;
66

77
/**
8-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#contracts">...</a>
8+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/contracts">...</a>
99
*
1010
* @author GoodforGod
1111
* @since 28.10.2018

src/main/java/io/goodforgod/api/etherscan/LogsAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.jetbrains.annotations.NotNull;
88

99
/**
10-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#logs">...</a>
10+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/logs">...</a>
1111
*
1212
* @author GoodforGod
1313
* @since 30.10.2018

src/main/java/io/goodforgod/api/etherscan/ProxyAPI.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
import org.jetbrains.annotations.NotNull;
1111

1212
/**
13-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#proxy">...</a>
13+
* EtherScan - API Descriptions
14+
* <a href="https://docs.etherscan.io/api-endpoints/geth-parity-proxy">...</a>
1415
*
1516
* @author GoodforGod
1617
* @since 30.10.2018

src/main/java/io/goodforgod/api/etherscan/ProxyAPIProvider.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ public Optional<String> storageAt(String address, long position) throws EtherSca
208208
public Wei gasPrice() throws EtherScanException {
209209
final StringProxyTO response = getRequest(ACT_GASPRICE_PARAM, StringProxyTO.class);
210210
return (BasicUtils.isEmpty(response.getResult()))
211-
? new Wei(0)
212-
: new Wei(BasicUtils.parseHex(response.getResult()));
211+
? Wei.ofWei(0)
212+
: Wei.ofWei(BasicUtils.parseHex(response.getResult()));
213213
}
214214

215215
@NotNull
@@ -227,7 +227,7 @@ public Wei gasEstimated(String hexData) throws EtherScanException {
227227
final String urlParams = ACT_ESTIMATEGAS_PARAM + DATA_PARAM + hexData + GAS_PARAM + "2000000000000000";
228228
final StringProxyTO response = getRequest(urlParams, StringProxyTO.class);
229229
return (BasicUtils.isEmpty(response.getResult()))
230-
? new Wei(0)
231-
: new Wei(BasicUtils.parseHex(response.getResult()));
230+
? Wei.ofWei(0)
231+
: Wei.ofWei(BasicUtils.parseHex(response.getResult()));
232232
}
233233
}
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package io.goodforgod.api.etherscan;
22

33
import io.goodforgod.api.etherscan.error.EtherScanException;
4+
import io.goodforgod.api.etherscan.model.EthSupply;
45
import io.goodforgod.api.etherscan.model.Price;
5-
import io.goodforgod.api.etherscan.model.Supply;
6-
import java.math.BigInteger;
6+
import io.goodforgod.api.etherscan.model.Wei;
77
import org.jetbrains.annotations.NotNull;
88

99
/**
10-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#stats">...</a>
10+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/stats-1">...</a>
1111
*
1212
* @author GoodforGod
1313
* @since 30.10.2018
@@ -16,22 +16,35 @@ public interface StatisticAPI {
1616

1717
/**
1818
* ERC20 token total Supply
19-
*
19+
* <a href=
20+
* "https://docs.etherscan.io/api-endpoints/tokens#get-erc20-token-totalsupply-by-contractaddress">EtherScan<a>
21+
*
2022
* @param contract contract address
2123
* @return token supply for specified contract
2224
* @throws EtherScanException parent exception class
2325
*/
2426
@NotNull
25-
BigInteger supply(String contract) throws EtherScanException;
27+
Wei supply(String contract) throws EtherScanException;
2628

2729
/**
28-
* Eth total supply
30+
* Returns the current amount of Ether in circulation excluding ETH2 Staking rewards and EIP1559
31+
* burnt fees.
2932
*
3033
* @return total ETH supply for moment
3134
* @throws EtherScanException parent exception class
3235
*/
3336
@NotNull
34-
Supply supply() throws EtherScanException;
37+
Wei supply() throws EtherScanException;
38+
39+
/**
40+
* Returns the current amount of Ether in circulation, ETH2 Staking rewards, EIP1559 burnt fees, and
41+
* total withdrawn ETH from the beacon chain.
42+
*
43+
* @return total ETH supply for moment
44+
* @throws EtherScanException parent exception class
45+
*/
46+
@NotNull
47+
EthSupply supplyTotal() throws EtherScanException;
3548

3649
/**
3750
* Eth last USD and BTC price
@@ -40,5 +53,5 @@ public interface StatisticAPI {
4053
* @throws EtherScanException parent exception class
4154
*/
4255
@NotNull
43-
Price lastPrice() throws EtherScanException;
56+
Price priceLast() throws EtherScanException;
4457
}

src/main/java/io/goodforgod/api/etherscan/StatisticAPIProvider.java

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
import io.goodforgod.api.etherscan.error.EtherScanResponseException;
55
import io.goodforgod.api.etherscan.http.EthHttpClient;
66
import io.goodforgod.api.etherscan.manager.RequestQueueManager;
7+
import io.goodforgod.api.etherscan.model.EthSupply;
78
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;
911
import io.goodforgod.api.etherscan.model.response.PriceResponseTO;
1012
import io.goodforgod.api.etherscan.model.response.StringResponseTO;
1113
import io.goodforgod.api.etherscan.util.BasicUtils;
@@ -22,6 +24,7 @@
2224
final 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);

src/main/java/io/goodforgod/api/etherscan/TransactionAPI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import org.jetbrains.annotations.NotNull;
77

88
/**
9-
* EtherScan - API Descriptions <a href="https://etherscan.io/apis#transactions">...</a>
9+
* EtherScan - API Descriptions <a href="https://docs.etherscan.io/api-endpoints/stats">...</a>
1010
*
1111
* @author GoodforGod
1212
* @since 30.10.2018

0 commit comments

Comments
 (0)