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

Commit225b211

Browse files
committed
[2.0.0-SNAPSHOT]
Tx Responses restoredGasOracle refactored and improvedModelBuilderTests added
1 parenta9dd8e0 commit225b211

24 files changed

+407
-63
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class Block {
1818
@Expose(deserialize =false,serialize =false)
1919
LocalDateTime_timeStamp;
2020

21+
protectedBlock() {}
22+
2123
// <editor-fold desc="Getter">
2224
publiclonggetBlockNumber() {
2325
returnblockNumber;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public static class Uncle {
1818
privateBigIntegerblockreward;
1919
privateintunclePosition;
2020

21+
privateUncle() {}
22+
2123
// <editor-fold desc="Getters">
2224
publicStringgetMiner() {
2325
returnminer;
@@ -113,6 +115,10 @@ public Uncle build() {
113115
privateList<Uncle>uncles;
114116
privateStringuncleInclusionReward;
115117

118+
protectedBlockUncle() {
119+
super();
120+
}
121+
116122
// <editor-fold desc="Getters">
117123
publicbooleanisEmpty() {
118124
returngetBlockNumber() ==0 &&getBlockReward() ==null

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

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

3+
importjava.math.BigDecimal;
34
importjava.math.BigInteger;
5+
importjava.util.Arrays;
6+
importjava.util.List;
47
importjava.util.Objects;
8+
importjava.util.stream.Collectors;
59

610
/**
711
* @author Abhay Gupta
@@ -16,28 +20,32 @@ public class GasOracle {
1620
privateDoublesuggestBaseFee;
1721
privateStringgasUsedRatio;
1822

23+
protectedGasOracle() {}
24+
1925
publicLonggetLastBlock() {
2026
returnLastBlock;
2127
}
2228

23-
publicBigIntegergetSafeGasPriceInWei() {
24-
returnBigInteger.valueOf(SafeGasPrice).multiply(BigInteger.TEN.pow(9));
29+
publicWeigetSafeGasPriceInWei() {
30+
returnnewWei(BigInteger.valueOf(SafeGasPrice).multiply(BigInteger.TEN.pow(9)));
2531
}
2632

27-
publicBigIntegergetProposeGasPriceInWei() {
28-
returnBigInteger.valueOf(ProposeGasPrice).multiply(BigInteger.TEN.pow(9));
33+
publicWeigetProposeGasPriceInWei() {
34+
returnnewWei(BigInteger.valueOf(ProposeGasPrice).multiply(BigInteger.TEN.pow(9)));
2935
}
3036

31-
publicBigIntegergetFastGasPriceInWei() {
32-
returnBigInteger.valueOf(FastGasPrice).multiply(BigInteger.TEN.pow(9));
37+
publicWeigetFastGasPriceInWei() {
38+
returnnewWei(BigInteger.valueOf(FastGasPrice).multiply(BigInteger.TEN.pow(9)));
3339
}
3440

3541
publicDoublegetSuggestBaseFee() {
3642
returnsuggestBaseFee;
3743
}
3844

39-
publicStringgetGasUsedRatio() {
40-
returngasUsedRatio;
45+
publicList<BigDecimal>getGasUsedRatio() {
46+
returnArrays.stream(gasUsedRatio.split(","))
47+
.map(BigDecimal::new)
48+
.collect(Collectors.toList());
4149
}
4250

4351
@Override
@@ -75,32 +83,32 @@ public static GasOracleBuilder builder() {
7583

7684
publicstaticfinalclassGasOracleBuilder {
7785

78-
privateLongLastBlock;
79-
privateIntegerSafeGasPrice;
80-
privateIntegerProposeGasPrice;
81-
privateIntegerFastGasPrice;
86+
privateLonglastBlock;
87+
privateWeisafeGasPrice;
88+
privateWeiproposeGasPrice;
89+
privateWeifastGasPrice;
8290
privateDoublesuggestBaseFee;
83-
privateStringgasUsedRatio;
91+
privateList<BigDecimal>gasUsedRatio;
8492

8593
privateGasOracleBuilder() {}
8694

87-
publicGasOracleBuilderwithLastBlock(LongLastBlock) {
88-
this.LastBlock =LastBlock;
95+
publicGasOracleBuilderwithLastBlock(LonglastBlock) {
96+
this.lastBlock =lastBlock;
8997
returnthis;
9098
}
9199

92-
publicGasOracleBuilderwithSafeGasPrice(IntegerSafeGasPrice) {
93-
this.SafeGasPrice =SafeGasPrice;
100+
publicGasOracleBuilderwithSafeGasPrice(WeisafeGasPrice) {
101+
this.safeGasPrice =safeGasPrice;
94102
returnthis;
95103
}
96104

97-
publicGasOracleBuilderwithProposeGasPrice(IntegerProposeGasPrice) {
98-
this.ProposeGasPrice =ProposeGasPrice;
105+
publicGasOracleBuilderwithProposeGasPrice(WeiproposeGasPrice) {
106+
this.proposeGasPrice =proposeGasPrice;
99107
returnthis;
100108
}
101109

102-
publicGasOracleBuilderwithFastGasPrice(IntegerFastGasPrice) {
103-
this.FastGasPrice =FastGasPrice;
110+
publicGasOracleBuilderwithFastGasPrice(WeifastGasPrice) {
111+
this.fastGasPrice =fastGasPrice;
104112
returnthis;
105113
}
106114

@@ -109,19 +117,29 @@ public GasOracleBuilder withSuggestBaseFee(Double suggestBaseFee) {
109117
returnthis;
110118
}
111119

112-
publicGasOracleBuilderwithGasUsedRatio(StringgasUsedRatio) {
120+
publicGasOracleBuilderwithGasUsedRatio(List<BigDecimal>gasUsedRatio) {
113121
this.gasUsedRatio =gasUsedRatio;
114122
returnthis;
115123
}
116124

117125
publicGasOraclebuild() {
118126
GasOraclegasOracle =newGasOracle();
119-
gasOracle.ProposeGasPrice =this.ProposeGasPrice;
120-
gasOracle.LastBlock =this.LastBlock;
127+
gasOracle.LastBlock =this.lastBlock;
121128
gasOracle.suggestBaseFee =this.suggestBaseFee;
122-
gasOracle.SafeGasPrice =this.SafeGasPrice;
123-
gasOracle.FastGasPrice =this.FastGasPrice;
124-
gasOracle.gasUsedRatio =this.gasUsedRatio;
129+
if (this.proposeGasPrice !=null) {
130+
gasOracle.ProposeGasPrice =this.proposeGasPrice.asGwei().intValue();
131+
}
132+
if (this.safeGasPrice !=null) {
133+
gasOracle.SafeGasPrice =this.safeGasPrice.asGwei().intValue();
134+
}
135+
if (this.fastGasPrice !=null) {
136+
gasOracle.FastGasPrice =this.fastGasPrice.asGwei().intValue();
137+
}
138+
if (this.gasUsedRatio !=null) {
139+
gasOracle.gasUsedRatio =this.gasUsedRatio.stream()
140+
.map(BigDecimal::toString)
141+
.collect(Collectors.joining(", "));
142+
}
125143
returngasOracle;
126144
}
127145
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public class Log {
3737
@Expose(deserialize =false,serialize =false)
3838
privateLong_logIndex;
3939

40+
protectedLog() {}
41+
4042
// <editor-fold desc="Getters">
4143
publicLonggetBlockNumber() {
4244
if (_blockNumber ==null && !BasicUtils.isEmpty(blockNumber)) {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class Price {
1919
@Expose(deserialize =false,serialize =false)
2020
privateLocalDateTime_ethbtc_timestamp;
2121

22+
protectedPrice() {}
23+
2224
publicdoubleinUsd() {
2325
returnethusd;
2426
}
@@ -101,22 +103,22 @@ public static final class PriceBuilder {
101103

102104
privatePriceBuilder() {}
103105

104-
publicPriceBuilderwithEthusd(doubleethusd) {
106+
publicPriceBuilderwithEthUsd(doubleethusd) {
105107
this.ethusd =ethusd;
106108
returnthis;
107109
}
108110

109-
publicPriceBuilderwithEthbtc(doubleethbtc) {
111+
publicPriceBuilderwithEthBtc(doubleethbtc) {
110112
this.ethbtc =ethbtc;
111113
returnthis;
112114
}
113115

114-
publicPriceBuilderwithEthusdTimestamp(LocalDateTimeethusdTimestamp) {
116+
publicPriceBuilderwithEthUsdTimestamp(LocalDateTimeethusdTimestamp) {
115117
this.ethusdTimestamp =ethusdTimestamp;
116118
returnthis;
117119
}
118120

119-
publicPriceBuilderwithEthbtcTimestamp(LocalDateTimeethbtcTimestamp) {
121+
publicPriceBuilderwithEthBtcTimestamp(LocalDateTimeethbtcTimestamp) {
120122
this.ethbtcTimestamp =ethbtcTimestamp;
121123
returnthis;
122124
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ public class Status {
1616
privateintisError;
1717
privateStringerrDescription;
1818

19+
protectedStatus() {}
20+
1921
publicbooleanhaveError() {
2022
returnisError ==1;
2123
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public class Tx extends BaseTx {
2222
privateStringisError;
2323
privateStringtxreceipt_status;
2424

25+
protectedTx() {}
26+
2527
// <editor-fold desc="Getters">
2628
publicBigIntegergetValue() {
2729
returnvalue;

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public class TxErc1155 extends BaseTx {
1818
privateStringtokenSymbol;
1919
privateStringtokenValue;
2020
privateinttransactionIndex;
21-
privatelonggasPrice;
22-
privatelongcumulativeGasUsed;
21+
privateBigIntegergasPrice;
22+
privateBigIntegercumulativeGasUsed;
2323
privatelongconfirmations;
2424

25+
protectedTxErc1155() {}
26+
2527
// <editor-fold desc="Getters">
2628
publiclonggetNonce() {
2729
returnnonce;
@@ -51,11 +53,11 @@ public int getTransactionIndex() {
5153
returntransactionIndex;
5254
}
5355

54-
publiclonggetGasPrice() {
56+
publicBigIntegergetGasPrice() {
5557
returngasPrice;
5658
}
5759

58-
publiclonggetCumulativeGasUsed() {
60+
publicBigIntegergetCumulativeGasUsed() {
5961
returncumulativeGasUsed;
6062
}
6163

@@ -120,8 +122,8 @@ public static final class TxErc1155Builder {
120122
privateStringtokenSymbol;
121123
privateStringtokenValue;
122124
privateinttransactionIndex;
123-
privatelonggasPrice;
124-
privatelongcumulativeGasUsed;
125+
privateBigIntegergasPrice;
126+
privateBigIntegercumulativeGasUsed;
125127
privatelongconfirmations;
126128

127129
privateTxErc1155Builder() {}
@@ -206,12 +208,12 @@ public TxErc1155Builder withTransactionIndex(int transactionIndex) {
206208
returnthis;
207209
}
208210

209-
publicTxErc1155BuilderwithGasPrice(longgasPrice) {
211+
publicTxErc1155BuilderwithGasPrice(BigIntegergasPrice) {
210212
this.gasPrice =gasPrice;
211213
returnthis;
212214
}
213215

214-
publicTxErc1155BuilderwithCumulativeGasUsed(longcumulativeGasUsed) {
216+
publicTxErc1155BuilderwithCumulativeGasUsed(BigIntegercumulativeGasUsed) {
215217
this.cumulativeGasUsed =cumulativeGasUsed;
216218
returnthis;
217219
}

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public class TxErc20 extends BaseTx {
1818
privateStringtokenSymbol;
1919
privateStringtokenDecimal;
2020
privateinttransactionIndex;
21-
privatelonggasPrice;
22-
privatelongcumulativeGasUsed;
21+
privateBigIntegergasPrice;
22+
privateBigIntegercumulativeGasUsed;
2323
privatelongconfirmations;
2424

25+
protectedTxErc20() {}
26+
2527
// <editor-fold desc="Getters">
2628
publiclonggetNonce() {
2729
returnnonce;
@@ -51,11 +53,11 @@ public int getTransactionIndex() {
5153
returntransactionIndex;
5254
}
5355

54-
publiclonggetGasPrice() {
56+
publicBigIntegergetGasPrice() {
5557
returngasPrice;
5658
}
5759

58-
publiclonggetCumulativeGasUsed() {
60+
publicBigIntegergetCumulativeGasUsed() {
5961
returncumulativeGasUsed;
6062
}
6163

@@ -120,8 +122,8 @@ public static final class TxERC20Builder {
120122
privateStringtokenSymbol;
121123
privateStringtokenDecimal;
122124
privateinttransactionIndex;
123-
privatelonggasPrice;
124-
privatelongcumulativeGasUsed;
125+
privateBigIntegergasPrice;
126+
privateBigIntegercumulativeGasUsed;
125127
privatelongconfirmations;
126128

127129
privateTxERC20Builder() {}
@@ -206,12 +208,12 @@ public TxERC20Builder withTransactionIndex(int transactionIndex) {
206208
returnthis;
207209
}
208210

209-
publicTxERC20BuilderwithGasPrice(longgasPrice) {
211+
publicTxERC20BuilderwithGasPrice(BigIntegergasPrice) {
210212
this.gasPrice =gasPrice;
211213
returnthis;
212214
}
213215

214-
publicTxERC20BuilderwithCumulativeGasUsed(longcumulativeGasUsed) {
216+
publicTxERC20BuilderwithCumulativeGasUsed(BigIntegercumulativeGasUsed) {
215217
this.cumulativeGasUsed =cumulativeGasUsed;
216218
returnthis;
217219
}

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ public class TxErc721 extends BaseTx {
1818
privateStringtokenSymbol;
1919
privateStringtokenDecimal;
2020
privateinttransactionIndex;
21-
privatelonggasPrice;
22-
privatelongcumulativeGasUsed;
21+
privateBigIntegergasPrice;
22+
privateBigIntegercumulativeGasUsed;
2323
privatelongconfirmations;
2424

25+
protectedTxErc721() {}
26+
2527
// <editor-fold desc="Getters">
2628
publiclonggetNonce() {
2729
returnnonce;
@@ -51,11 +53,11 @@ public int getTransactionIndex() {
5153
returntransactionIndex;
5254
}
5355

54-
publiclonggetGasPrice() {
56+
publicBigIntegergetGasPrice() {
5557
returngasPrice;
5658
}
5759

58-
publiclonggetCumulativeGasUsed() {
60+
publicBigIntegergetCumulativeGasUsed() {
5961
returncumulativeGasUsed;
6062
}
6163

@@ -120,8 +122,8 @@ public static final class TxERC721Builder {
120122
privateStringtokenSymbol;
121123
privateStringtokenDecimal;
122124
privateinttransactionIndex;
123-
privatelonggasPrice;
124-
privatelongcumulativeGasUsed;
125+
privateBigIntegergasPrice;
126+
privateBigIntegercumulativeGasUsed;
125127
privatelongconfirmations;
126128

127129
privateTxERC721Builder() {}
@@ -206,12 +208,12 @@ public TxERC721Builder withTransactionIndex(int transactionIndex) {
206208
returnthis;
207209
}
208210

209-
publicTxERC721BuilderwithGasPrice(longgasPrice) {
211+
publicTxERC721BuilderwithGasPrice(BigIntegergasPrice) {
210212
this.gasPrice =gasPrice;
211213
returnthis;
212214
}
213215

214-
publicTxERC721BuilderwithCumulativeGasUsed(longcumulativeGasUsed) {
216+
publicTxERC721BuilderwithCumulativeGasUsed(BigIntegercumulativeGasUsed) {
215217
this.cumulativeGasUsed =cumulativeGasUsed;
216218
returnthis;
217219
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp