Skip to content

Commit 6d19b73

Browse files
committed
[2.0.0-SNAPSHOT]
Gas related fields replaced to Wei
1 parent 63f8909 commit 6d19b73

File tree

10 files changed

+180
-144
lines changed

10 files changed

+180
-144
lines changed

src/main/java/io/goodforgod/api/etherscan/model/BaseTx.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,12 @@ public String getInput() {
5656
return input;
5757
}
5858

59-
public BigInteger getGas() {
60-
return gas;
59+
public Wei getGas() {
60+
return Wei.ofWei(gas);
6161
}
6262

63-
public BigInteger getGasUsed() {
64-
return gasUsed;
63+
public Wei getGasUsed() {
64+
return Wei.ofWei(gasUsed);
6565
}
6666
// </editor-fold>
6767

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

+29-21
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@ public int getTransactionIndex() {
4141
return transactionIndex;
4242
}
4343

44-
public BigInteger getGasPrice() {
45-
return gasPrice;
44+
public Wei getGasPrice() {
45+
return Wei.ofWei(gasPrice);
4646
}
4747

4848
public boolean haveError() {
4949
return !BasicUtils.isEmpty(isError) && !isError.equals("0");
5050
}
5151

52-
public String getTxreceipt_status() {
52+
public String getTxReceiptStatus() {
5353
return txreceipt_status;
5454
}
5555

56-
public BigInteger getCumulativeGasUsed() {
57-
return cumulativeGasUsed;
56+
public Wei getGasUsedCumulative() {
57+
return Wei.ofWei(cumulativeGasUsed);
5858
}
5959

6060
public long getConfirmations() {
@@ -112,16 +112,16 @@ public static final class TxBuilder {
112112
private BigInteger value;
113113
private String contractAddress;
114114
private String input;
115-
private BigInteger gas;
116-
private BigInteger gasUsed;
115+
private Wei gas;
116+
private Wei gasUsed;
117117
private long nonce;
118118
private String blockHash;
119119
private int transactionIndex;
120-
private BigInteger gasPrice;
121-
private BigInteger cumulativeGasUsed;
120+
private Wei gasPrice;
121+
private Wei cumulativeGasUsed;
122122
private long confirmations;
123123
private String isError;
124-
private String txreceiptStatus;
124+
private String txReceiptStatus;
125125

126126
private TxBuilder() {}
127127

@@ -165,12 +165,12 @@ public TxBuilder withInput(String input) {
165165
return this;
166166
}
167167

168-
public TxBuilder withGas(BigInteger gas) {
168+
public TxBuilder withGas(Wei gas) {
169169
this.gas = gas;
170170
return this;
171171
}
172172

173-
public TxBuilder withGasUsed(BigInteger gasUsed) {
173+
public TxBuilder withGasUsed(Wei gasUsed) {
174174
this.gasUsed = gasUsed;
175175
return this;
176176
}
@@ -190,12 +190,12 @@ public TxBuilder withTransactionIndex(int transactionIndex) {
190190
return this;
191191
}
192192

193-
public TxBuilder withGasPrice(BigInteger gasPrice) {
193+
public TxBuilder withGasPrice(Wei gasPrice) {
194194
this.gasPrice = gasPrice;
195195
return this;
196196
}
197197

198-
public TxBuilder withCumulativeGasUsed(BigInteger cumulativeGasUsed) {
198+
public TxBuilder withCumulativeGasUsed(Wei cumulativeGasUsed) {
199199
this.cumulativeGasUsed = cumulativeGasUsed;
200200
return this;
201201
}
@@ -210,20 +210,30 @@ public TxBuilder withIsError(String isError) {
210210
return this;
211211
}
212212

213-
public TxBuilder withTxreceiptStatus(String txreceiptStatus) {
214-
this.txreceiptStatus = txreceiptStatus;
213+
public TxBuilder withTxReceiptStatus(String txReceiptStatus) {
214+
this.txReceiptStatus = txReceiptStatus;
215215
return this;
216216
}
217217

218218
public Tx build() {
219219
Tx tx = new Tx();
220-
tx.gas = this.gas;
221220
tx.isError = this.isError;
222221
tx.blockHash = this.blockHash;
223222
tx.hash = this.hash;
224-
tx.gasUsed = this.gasUsed;
223+
if (this.gas != null) {
224+
tx.gas = this.gas.asWei();
225+
}
226+
if (this.gasUsed != null) {
227+
tx.gasUsed = this.gasUsed.asWei();
228+
}
229+
if (this.gasPrice != null) {
230+
tx.gasPrice = this.gasPrice.asWei();
231+
}
232+
if (this.cumulativeGasUsed != null) {
233+
tx.cumulativeGasUsed = this.cumulativeGasUsed.asWei();
234+
}
225235
tx.from = this.from;
226-
tx.txreceipt_status = this.txreceiptStatus;
236+
tx.txreceipt_status = this.txReceiptStatus;
227237
tx.contractAddress = this.contractAddress;
228238
tx.value = this.value;
229239
tx.transactionIndex = this.transactionIndex;
@@ -236,8 +246,6 @@ public Tx build() {
236246
tx.blockNumber = this.blockNumber;
237247
tx.to = this.to;
238248
tx.input = this.input;
239-
tx.cumulativeGasUsed = this.cumulativeGasUsed;
240-
tx.gasPrice = this.gasPrice;
241249
return tx;
242250
}
243251
}

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

+42-34
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ public int getTransactionIndex() {
5353
return transactionIndex;
5454
}
5555

56-
public BigInteger getGasPrice() {
57-
return gasPrice;
56+
public Wei getGasPrice() {
57+
return Wei.ofWei(gasPrice);
5858
}
5959

60-
public BigInteger getCumulativeGasUsed() {
61-
return cumulativeGasUsed;
60+
public Wei getGasUsedCumulative() {
61+
return Wei.ofWei(cumulativeGasUsed);
6262
}
6363

6464
public long getConfirmations() {
@@ -113,17 +113,17 @@ public static final class TxErc1155Builder {
113113
private String to;
114114
private String contractAddress;
115115
private String input;
116-
private BigInteger gas;
117-
private BigInteger gasUsed;
118116
private long nonce;
119117
private String blockHash;
120118
private String tokenID;
121119
private String tokenName;
122120
private String tokenSymbol;
123121
private String tokenValue;
124122
private int transactionIndex;
125-
private BigInteger gasPrice;
126-
private BigInteger cumulativeGasUsed;
123+
private Wei gas;
124+
private Wei gasUsed;
125+
private Wei gasPrice;
126+
private Wei cumulativeGasUsed;
127127
private long confirmations;
128128

129129
private TxErc1155Builder() {}
@@ -163,12 +163,12 @@ public TxErc1155Builder withInput(String input) {
163163
return this;
164164
}
165165

166-
public TxErc1155Builder withGas(BigInteger gas) {
166+
public TxErc1155Builder withGas(Wei gas) {
167167
this.gas = gas;
168168
return this;
169169
}
170170

171-
public TxErc1155Builder withGasUsed(BigInteger gasUsed) {
171+
public TxErc1155Builder withGasUsed(Wei gasUsed) {
172172
this.gasUsed = gasUsed;
173173
return this;
174174
}
@@ -208,12 +208,12 @@ public TxErc1155Builder withTransactionIndex(int transactionIndex) {
208208
return this;
209209
}
210210

211-
public TxErc1155Builder withGasPrice(BigInteger gasPrice) {
211+
public TxErc1155Builder withGasPrice(Wei gasPrice) {
212212
this.gasPrice = gasPrice;
213213
return this;
214214
}
215215

216-
public TxErc1155Builder withCumulativeGasUsed(BigInteger cumulativeGasUsed) {
216+
public TxErc1155Builder withCumulativeGasUsed(Wei cumulativeGasUsed) {
217217
this.cumulativeGasUsed = cumulativeGasUsed;
218218
return this;
219219
}
@@ -224,30 +224,38 @@ public TxErc1155Builder withConfirmations(long confirmations) {
224224
}
225225

226226
public TxErc1155 build() {
227-
TxErc1155 txERC721 = new TxErc1155();
228-
txERC721.gas = this.gas;
229-
txERC721.tokenName = this.tokenName;
230-
txERC721.hash = this.hash;
231-
txERC721.gasUsed = this.gasUsed;
232-
txERC721.nonce = this.nonce;
233-
txERC721.from = this.from;
234-
txERC721.gasPrice = this.gasPrice;
235-
txERC721.contractAddress = this.contractAddress;
236-
txERC721.cumulativeGasUsed = this.cumulativeGasUsed;
237-
txERC721.tokenID = this.tokenID;
227+
TxErc1155 txERC1155 = new TxErc1155();
228+
txERC1155.tokenName = this.tokenName;
229+
txERC1155.hash = this.hash;
230+
txERC1155.nonce = this.nonce;
231+
txERC1155.from = this.from;
232+
if (this.gas != null) {
233+
txERC1155.gas = this.gas.asWei();
234+
}
235+
if (this.gasUsed != null) {
236+
txERC1155.gasUsed = this.gasUsed.asWei();
237+
}
238+
if (this.gasPrice != null) {
239+
txERC1155.gasPrice = this.gasPrice.asWei();
240+
}
241+
if (this.cumulativeGasUsed != null) {
242+
txERC1155.cumulativeGasUsed = this.cumulativeGasUsed.asWei();
243+
}
244+
txERC1155.contractAddress = this.contractAddress;
245+
txERC1155.tokenID = this.tokenID;
238246
if (this.timeStamp != null) {
239-
txERC721.timeStamp = String.valueOf(this.timeStamp.toEpochSecond(ZoneOffset.UTC));
240-
txERC721._timeStamp = this.timeStamp;
247+
txERC1155.timeStamp = String.valueOf(this.timeStamp.toEpochSecond(ZoneOffset.UTC));
248+
txERC1155._timeStamp = this.timeStamp;
241249
}
242-
txERC721.blockNumber = this.blockNumber;
243-
txERC721.tokenValue = this.tokenValue;
244-
txERC721.transactionIndex = this.transactionIndex;
245-
txERC721.to = this.to;
246-
txERC721.confirmations = this.confirmations;
247-
txERC721.input = this.input;
248-
txERC721.blockHash = this.blockHash;
249-
txERC721.tokenSymbol = this.tokenSymbol;
250-
return txERC721;
250+
txERC1155.blockNumber = this.blockNumber;
251+
txERC1155.tokenValue = this.tokenValue;
252+
txERC1155.transactionIndex = this.transactionIndex;
253+
txERC1155.to = this.to;
254+
txERC1155.confirmations = this.confirmations;
255+
txERC1155.input = this.input;
256+
txERC1155.blockHash = this.blockHash;
257+
txERC1155.tokenSymbol = this.tokenSymbol;
258+
return txERC1155;
251259
}
252260
}
253261
}

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

+24-16
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ public int getTransactionIndex() {
5353
return transactionIndex;
5454
}
5555

56-
public BigInteger getGasPrice() {
57-
return gasPrice;
56+
public Wei getGasPrice() {
57+
return Wei.ofWei(gasPrice);
5858
}
5959

60-
public BigInteger getCumulativeGasUsed() {
61-
return cumulativeGasUsed;
60+
public Wei getGasUsedCumulative() {
61+
return Wei.ofWei(cumulativeGasUsed);
6262
}
6363

6464
public long getConfirmations() {
@@ -114,16 +114,16 @@ public static final class TxERC20Builder {
114114
private BigInteger value;
115115
private String contractAddress;
116116
private String input;
117-
private BigInteger gas;
118-
private BigInteger gasUsed;
117+
private Wei gas;
118+
private Wei gasUsed;
119119
private long nonce;
120120
private String blockHash;
121121
private String tokenName;
122122
private String tokenSymbol;
123123
private String tokenDecimal;
124124
private int transactionIndex;
125-
private BigInteger gasPrice;
126-
private BigInteger cumulativeGasUsed;
125+
private Wei gasPrice;
126+
private Wei cumulativeGasUsed;
127127
private long confirmations;
128128

129129
private TxERC20Builder() {}
@@ -168,12 +168,12 @@ public TxERC20Builder withInput(String input) {
168168
return this;
169169
}
170170

171-
public TxERC20Builder withGas(BigInteger gas) {
171+
public TxERC20Builder withGas(Wei gas) {
172172
this.gas = gas;
173173
return this;
174174
}
175175

176-
public TxERC20Builder withGasUsed(BigInteger gasUsed) {
176+
public TxERC20Builder withGasUsed(Wei gasUsed) {
177177
this.gasUsed = gasUsed;
178178
return this;
179179
}
@@ -208,12 +208,12 @@ public TxERC20Builder withTransactionIndex(int transactionIndex) {
208208
return this;
209209
}
210210

211-
public TxERC20Builder withGasPrice(BigInteger gasPrice) {
211+
public TxERC20Builder withGasPrice(Wei gasPrice) {
212212
this.gasPrice = gasPrice;
213213
return this;
214214
}
215215

216-
public TxERC20Builder withCumulativeGasUsed(BigInteger cumulativeGasUsed) {
216+
public TxERC20Builder withCumulativeGasUsed(Wei cumulativeGasUsed) {
217217
this.cumulativeGasUsed = cumulativeGasUsed;
218218
return this;
219219
}
@@ -225,11 +225,20 @@ public TxERC20Builder withConfirmations(long confirmations) {
225225

226226
public TxErc20 build() {
227227
TxErc20 txERC20 = new TxErc20();
228-
txERC20.gas = this.gas;
229228
txERC20.tokenName = this.tokenName;
230229
txERC20.hash = this.hash;
231-
txERC20.gasUsed = this.gasUsed;
232-
txERC20.cumulativeGasUsed = this.cumulativeGasUsed;
230+
if (this.gas != null) {
231+
txERC20.gas = this.gas.asWei();
232+
}
233+
if (this.gasUsed != null) {
234+
txERC20.gasUsed = this.gasUsed.asWei();
235+
}
236+
if (this.gasPrice != null) {
237+
txERC20.gasPrice = this.gasPrice.asWei();
238+
}
239+
if (this.cumulativeGasUsed != null) {
240+
txERC20.cumulativeGasUsed = this.cumulativeGasUsed.asWei();
241+
}
233242
txERC20.from = this.from;
234243
txERC20.tokenSymbol = this.tokenSymbol;
235244
txERC20.transactionIndex = this.transactionIndex;
@@ -243,7 +252,6 @@ public TxErc20 build() {
243252
}
244253
txERC20.blockHash = this.blockHash;
245254
txERC20.blockNumber = this.blockNumber;
246-
txERC20.gasPrice = this.gasPrice;
247255
txERC20.to = this.to;
248256
txERC20.input = this.input;
249257
txERC20.tokenDecimal = this.tokenDecimal;

0 commit comments

Comments
 (0)