Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1beaafd

Browse files
committed
[2.0.0-SNAPSHOT]
Balance contract improvedWei contract improvedSupply constructor addedProxyAPI contract refactored to Wei
1 parent873f582 commit1beaafd

File tree

10 files changed

+33
-49
lines changed

10 files changed

+33
-49
lines changed

‎src/main/java/io/goodforgod/api/etherscan/GasTrackerAPIProvider.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ final class GasTrackerAPIProvider extends BasicProvider implements GasTrackerAPI
3434

3535
@Override
3636
public@NotNullGasEstimateestimate(@NotNullWeiwei)throwsEtherScanException {
37-
finalStringurlParams =ACT_GAS_ESTIMATE_PARAM +GASPRICE_PARAM +wei.getValue().toString();
37+
finalStringurlParams =ACT_GAS_ESTIMATE_PARAM +GASPRICE_PARAM +wei.asWei().toString();
3838
finalGasEstimateResponseTOresponse =getRequest(urlParams,GasEstimateResponseTO.class);
3939
if (response.getStatus() !=1)
4040
thrownewEtherScanResponseException(response);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
packageio.goodforgod.api.etherscan;
22

33
importio.goodforgod.api.etherscan.error.EtherScanException;
4+
importio.goodforgod.api.etherscan.model.Wei;
45
importio.goodforgod.api.etherscan.model.proxy.BlockProxy;
56
importio.goodforgod.api.etherscan.model.proxy.ReceiptProxy;
67
importio.goodforgod.api.etherscan.model.proxy.TxProxy;
7-
importjava.math.BigInteger;
88
importjava.util.Optional;
99
importorg.jetbrains.annotations.ApiStatus.Experimental;
1010
importorg.jetbrains.annotations.NotNull;
@@ -150,7 +150,7 @@ public interface ProxyAPI {
150150
* @throws EtherScanException parent exception class
151151
*/
152152
@NotNull
153-
BigIntegergasPrice()throwsEtherScanException;
153+
WeigasPrice()throwsEtherScanException;
154154

155155
/**
156156
* Makes a call or transaction, which won't be added to the blockchain and returns the used gas,
@@ -161,8 +161,8 @@ public interface ProxyAPI {
161161
* @throws EtherScanException parent exception class
162162
*/
163163
@NotNull
164-
BigIntegergasEstimated(StringhexData)throwsEtherScanException;
164+
WeigasEstimated(StringhexData)throwsEtherScanException;
165165

166166
@NotNull
167-
BigIntegergasEstimated()throwsEtherScanException;
167+
WeigasEstimated()throwsEtherScanException;
168168
}

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importio.goodforgod.api.etherscan.error.EtherScanResponseException;
66
importio.goodforgod.api.etherscan.http.EthHttpClient;
77
importio.goodforgod.api.etherscan.manager.RequestQueueManager;
8+
importio.goodforgod.api.etherscan.model.Wei;
89
importio.goodforgod.api.etherscan.model.proxy.BlockProxy;
910
importio.goodforgod.api.etherscan.model.proxy.ReceiptProxy;
1011
importio.goodforgod.api.etherscan.model.proxy.TxProxy;
@@ -13,7 +14,6 @@
1314
importio.goodforgod.api.etherscan.model.proxy.utility.TxInfoProxyTO;
1415
importio.goodforgod.api.etherscan.model.proxy.utility.TxProxyTO;
1516
importio.goodforgod.api.etherscan.util.BasicUtils;
16-
importjava.math.BigInteger;
1717
importjava.util.Optional;
1818
importjava.util.regex.Pattern;
1919
importorg.jetbrains.annotations.NotNull;
@@ -197,29 +197,29 @@ public Optional<String> storageAt(String address, long position) throws EtherSca
197197

198198
@NotNull
199199
@Override
200-
publicBigIntegergasPrice()throwsEtherScanException {
200+
publicWeigasPrice()throwsEtherScanException {
201201
finalStringProxyTOresponse =getRequest(ACT_GASPRICE_PARAM,StringProxyTO.class);
202202
return (BasicUtils.isEmpty(response.getResult()))
203-
?BigInteger.valueOf(-1)
204-
:BasicUtils.parseHex(response.getResult());
203+
?newWei(0)
204+
:newWei(BasicUtils.parseHex(response.getResult()));
205205
}
206206

207207
@NotNull
208208
@Override
209-
publicBigIntegergasEstimated()throwsEtherScanException {
209+
publicWeigasEstimated()throwsEtherScanException {
210210
returngasEstimated("606060405260728060106000396000f360606040526000");
211211
}
212212

213213
@NotNull
214214
@Override
215-
publicBigIntegergasEstimated(StringhexData)throwsEtherScanException {
215+
publicWeigasEstimated(StringhexData)throwsEtherScanException {
216216
if (!BasicUtils.isEmpty(hexData) &&BasicUtils.isNotHex(hexData))
217217
thrownewEtherScanInvalidDataHexException("Data is not in hex format.");
218218

219219
finalStringurlParams =ACT_ESTIMATEGAS_PARAM +DATA_PARAM +hexData +GAS_PARAM +"2000000000000000";
220220
finalStringProxyTOresponse =getRequest(urlParams,StringProxyTO.class);
221221
return (BasicUtils.isEmpty(response.getResult()))
222-
?BigInteger.valueOf(-1)
223-
:BasicUtils.parseHex(response.getResult());
222+
?newWei(0)
223+
:newWei(BasicUtils.parseHex(response.getResult()));
224224
}
225225
}

‎src/main/java/io/goodforgod/api/etherscan/manager/RequestQueueManager.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ public interface RequestQueueManager extends AutoCloseable {
1616
/**
1717
* Is used by default when no API KEY is provided
1818
*/
19-
RequestQueueManagerANONYMOUS =newSemaphoreRequestQueueManager(1,Duration.ofMillis(5005L));
19+
RequestQueueManagerANONYMOUS =newSemaphoreRequestQueueManager(1,Duration.ofMillis(5010L));
2020

2121
/**
2222
* Is available for all registered free API KEYs
2323
* <a href="https://docs.etherscan.io/getting-started/viewing-api-usage-statistics">Free API KEY</a>
2424
*/
25-
RequestQueueManagerFREE_PLAN =newSemaphoreRequestQueueManager(5,Duration.ofMillis(1005L));
25+
RequestQueueManagerFREE_PLAN =newSemaphoreRequestQueueManager(5,Duration.ofMillis(1010L));
2626

2727
RequestQueueManagerUNLIMITED =newFakeRequestQueueManager();
2828

‎src/main/java/io/goodforgod/api/etherscan/model/Balance.java‎

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,8 @@ public String getAddress() {
2323
returnaddress;
2424
}
2525

26-
publicBigIntegergetWei() {
27-
returnbalance.getValue();
28-
}
29-
30-
publicBigIntegergetKwei() {
31-
returnbalance.asKwei();
32-
}
33-
34-
publicBigIntegergetMwei() {
35-
returnbalance.asMwei();
36-
}
37-
38-
publicBigIntegergetGwei() {
39-
returnbalance.asGwei();
40-
}
41-
42-
publicBigIntegergetEther() {
43-
returnbalance.asEther();
26+
publicWeigetBalanceInWei() {
27+
returnbalance;
4428
}
4529
// </editor-fold>
4630

‎src/main/java/io/goodforgod/api/etherscan/model/Supply.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
*/
99
publicclassSupplyextendsWei {
1010

11+
publicSupply(longvalue) {
12+
super(value);
13+
}
14+
1115
publicSupply(BigIntegervalue) {
1216
super(value);
1317
}

‎src/main/java/io/goodforgod/api/etherscan/model/Wei.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public Wei(BigInteger value) {
2020
}
2121

2222
// <editor-fold desc="Getters">
23-
publicBigIntegergetValue() {
23+
publicBigIntegerasWei() {
2424
returnresult;
2525
}
2626

‎src/test/java/io/goodforgod/api/etherscan/account/AccountBalanceListTests.java‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,9 @@ void correct() {
2929
assertNotEquals(balances.get(0).hashCode(),balances.get(1).hashCode());
3030
for (Balancebalance :balances) {
3131
assertNotNull(balance.getAddress());
32-
assertNotNull(balance.getGwei());
33-
assertNotNull(balance.getKwei());
34-
assertNotNull(balance.getMwei());
35-
assertNotNull(balance.getEther());
36-
assertNotNull(balance.getGwei());
32+
assertNotNull(balance.getBalanceInWei());
3733
assertNotNull(balance.getAddress());
38-
assertNotEquals(BigInteger.ZERO,balance.getWei());
34+
assertNotEquals(BigInteger.ZERO,balance.getBalanceInWei().asWei());
3935
assertNotNull(balance.toString());
4036
}
4137
}
@@ -84,7 +80,7 @@ void correctParamWithEmptyExpectedResult() {
8480
assertEquals(2,balances.size());
8581
for (Balancebalance :balances) {
8682
assertNotNull(balance.getAddress());
87-
assertEquals(0,balance.getWei().intValue());
83+
assertEquals(0,balance.getBalanceInWei().asWei().intValue());
8884
}
8985
}
9086
}

‎src/test/java/io/goodforgod/api/etherscan/proxy/ProxyGasApiTests.java‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
importio.goodforgod.api.etherscan.ApiRunner;
44
importio.goodforgod.api.etherscan.error.EtherScanInvalidDataHexException;
5-
importjava.math.BigInteger;
5+
importio.goodforgod.api.etherscan.model.Wei;
66
importorg.junit.jupiter.api.Test;
77

88
/**
@@ -13,23 +13,23 @@ class ProxyGasApiTests extends ApiRunner {
1313

1414
@Test
1515
voidcorrectPrice() {
16-
BigIntegerprice =getApi().proxy().gasPrice();
16+
Weiprice =getApi().proxy().gasPrice();
1717
assertNotNull(price);
18-
assertNotEquals(0,price.intValue());
18+
assertNotEquals(0,price.asWei().intValue());
1919
}
2020

2121
@Test
2222
voidcorrectEstimated() {
23-
BigIntegerprice =getApi().proxy().gasEstimated();
23+
Weiprice =getApi().proxy().gasEstimated();
2424
assertNotNull(price);
25-
assertNotEquals(0,price.intValue());
25+
assertNotEquals(0,price.asWei().intValue());
2626
}
2727

2828
@Test
2929
voidcorrectEstimatedWithData() {
3030
StringdataCustom ="606060405260728060106000396000f360606040526000606060405260728060106000396000f360606040526000";
31-
BigIntegerprice =getApi().proxy().gasEstimated();
32-
BigIntegerpriceCustom =getApi().proxy().gasEstimated(dataCustom);
31+
Weiprice =getApi().proxy().gasEstimated();
32+
WeipriceCustom =getApi().proxy().gasEstimated(dataCustom);
3333
assertNotNull(price);
3434
assertNotNull(priceCustom);
3535
assertNotEquals(price,priceCustom);

‎src/test/java/io/goodforgod/api/etherscan/statistic/StatisticSupplyApiTests.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class StatisticSupplyApiTests extends ApiRunner {
1515
voidcorrect() {
1616
Supplysupply =getApi().stats().supply();
1717
assertNotNull(supply);
18-
assertNotNull(supply.getValue());
18+
assertNotNull(supply.asWei());
1919
assertNotNull(supply.asGwei());
2020
assertNotNull(supply.asKwei());
2121
assertNotNull(supply.asMwei());

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp