Skip to content

Commit 0b60b49

Browse files
committed
Other provider contracts introduced
Some models timestamp support improved
1 parent 73fd165 commit 0b60b49

14 files changed

+242
-5
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.api.core;
2+
3+
import io.api.model.UncleBlock;
4+
5+
/**
6+
* EtherScan - API Descriptions
7+
* https://etherscan.io/apis#blocks
8+
*
9+
* @author GoodforGod
10+
* @since 30.10.2018
11+
*/
12+
public interface IBlockProvider {
13+
14+
UncleBlock uncles(long blockNumber);
15+
}

src/main/java/io/api/core/IContractProvider.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package io.api.core;
22

33
/**
4-
* ! NO DESCRIPTION !
4+
* EtherScan - API Descriptions
5+
* https://etherscan.io/apis#contracts
56
*
67
* @author GoodforGod
78
* @since 28.10.2018
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.api.core;
2+
3+
/**
4+
* EtherScan - API Descriptions
5+
* https://etherscan.io/apis#logs
6+
*
7+
* @author GoodforGod
8+
* @since 30.10.2018
9+
*/
10+
public interface ILogsProvider {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.api.core;
2+
3+
/**
4+
* EtherScan - API Descriptions
5+
* https://etherscan.io/apis#proxy
6+
*
7+
* @author GoodforGod
8+
* @since 30.10.2018
9+
*/
10+
public interface IParityProvider {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.api.core;
2+
3+
/**
4+
* EtherScan - API Descriptions
5+
* https://etherscan.io/apis#stats
6+
*
7+
* @author GoodforGod
8+
* @since 30.10.2018
9+
*/
10+
public interface IStatisticProvider {
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package io.api.core;
2+
3+
/**
4+
* EtherScan - API Descriptions
5+
* https://etherscan.io/apis#tokens
6+
*
7+
* @author GoodforGod
8+
* @since 30.10.2018
9+
*/
10+
public interface ITokenProvider {
11+
12+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package io.api.core;
2+
3+
import io.api.model.Status;
4+
5+
/**
6+
* EtherScan - API Descriptions
7+
* https://etherscan.io/apis#transactions
8+
*
9+
* @author GoodforGod
10+
* @since 30.10.2018
11+
*/
12+
public interface ITransactionProvider {
13+
14+
Status execStatus(String txhash);
15+
16+
boolean receiptStatus(String txhash);
17+
}

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package io.api.model;
22

3+
import io.api.util.BasicUtils;
4+
35
import java.math.BigInteger;
6+
import java.time.LocalDateTime;
7+
import java.time.ZoneOffset;
48

59
/**
610
* ! NO DESCRIPTION !
@@ -12,6 +16,7 @@ abstract class BaseTx {
1216

1317
private long blockNumber;
1418
private String timeStamp;
19+
private LocalDateTime _timeStamp;
1520
private String hash;
1621
private String from;
1722
private String to;
@@ -26,8 +31,10 @@ public long getBlockNumber() {
2631
return blockNumber;
2732
}
2833

29-
public String getTimeStamp() {
30-
return timeStamp;
34+
public LocalDateTime getTimeStamp() {
35+
if(_timeStamp == null && !BasicUtils.isEmpty(timeStamp))
36+
_timeStamp = LocalDateTime.ofEpochSecond(Long.valueOf(timeStamp), 0, ZoneOffset.UTC);
37+
return _timeStamp;
3138
}
3239

3340
public String getHash() {

src/main/java/io/api/model/Block.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package io.api.model;
22

3+
import io.api.util.BasicUtils;
4+
5+
import java.time.LocalDateTime;
6+
import java.time.ZoneOffset;
7+
38
/**
49
* ! NO DESCRIPTION !
510
*
@@ -10,6 +15,7 @@ public class Block {
1015

1116
private String blockNumber;
1217
private String timeStamp;
18+
private LocalDateTime _timeStamp;
1319
private String blockReward;
1420

1521
public Block(String blockNumber, String timeStamp, String blockReward) {
@@ -23,8 +29,10 @@ public String getBlockNumber() {
2329
return blockNumber;
2430
}
2531

26-
public String getTimeStamp() {
27-
return timeStamp;
32+
public LocalDateTime getTimeStamp() {
33+
if(_timeStamp == null && !BasicUtils.isEmpty(timeStamp))
34+
_timeStamp = LocalDateTime.ofEpochSecond(Long.valueOf(timeStamp), 0, ZoneOffset.UTC);
35+
return _timeStamp;
2836
}
2937

3038
public String getBlockReward() {
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.api.model;
2+
3+
/**
4+
* ! NO DESCRIPTION !
5+
*
6+
* @author GoodforGod
7+
* @since 30.10.2018
8+
*/
9+
public class Status {
10+
11+
private int isError;
12+
private String errDescription;
13+
14+
public int getIsError() {
15+
return isError;
16+
}
17+
18+
public String getErrDescription() {
19+
return errDescription;
20+
}
21+
}

src/main/java/io/api/model/Uncle.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.api.model;
2+
3+
import java.math.BigInteger;
4+
5+
/**
6+
* ! NO DESCRIPTION !
7+
*
8+
* @author GoodforGod
9+
* @since 30.10.2018
10+
*/
11+
public class Uncle {
12+
13+
private String miner;
14+
private BigInteger blockreward;
15+
private int unclePosition;
16+
17+
//<editor-fold desc="Getters">
18+
public String getMiner() {
19+
return miner;
20+
}
21+
22+
public BigInteger getBlockreward() {
23+
return blockreward;
24+
}
25+
26+
public int getUnclePosition() {
27+
return unclePosition;
28+
}
29+
//</editor-fold>
30+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package io.api.model;
2+
3+
import io.api.util.BasicUtils;
4+
5+
import java.math.BigInteger;
6+
import java.time.LocalDateTime;
7+
import java.time.ZoneOffset;
8+
import java.util.List;
9+
10+
/**
11+
* ! NO DESCRIPTION !
12+
*
13+
* @author GoodforGod
14+
* @since 30.10.2018
15+
*/
16+
public class UncleBlock {
17+
18+
private long blockNumber;
19+
private BigInteger blockReward;
20+
private String blockMiner;
21+
private String timeStamp;
22+
private LocalDateTime _timeStamp;
23+
private List<Uncle> uncles;
24+
private String uncleInclusionReward;
25+
26+
//<editor-fold desc="Getters">
27+
28+
public LocalDateTime getTimeStamp() {
29+
if(_timeStamp == null && !BasicUtils.isEmpty(timeStamp))
30+
_timeStamp = LocalDateTime.ofEpochSecond(Long.valueOf(timeStamp), 0, ZoneOffset.UTC);
31+
return _timeStamp;
32+
}
33+
34+
public BigInteger getBlockReward() {
35+
return blockReward;
36+
}
37+
38+
public String getBlockMiner() {
39+
return blockMiner;
40+
}
41+
42+
public List<Uncle> getUncles() {
43+
return uncles;
44+
}
45+
46+
public String getUncleInclusionReward() {
47+
return uncleInclusionReward;
48+
}
49+
50+
public long getBlockNumber() {
51+
return blockNumber;
52+
}
53+
//</editor-fold>
54+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.api.model.temporary;
2+
3+
import io.api.model.Status;
4+
5+
/**
6+
* ! NO DESCRIPTION !
7+
*
8+
* @author GoodforGod
9+
* @since 30.10.2018
10+
*/
11+
public class StatusResponseTO extends BaseResponseTO {
12+
13+
private Status result;
14+
15+
public Status getResult() {
16+
return result;
17+
}
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.api.model.temporary;
2+
3+
import io.api.model.UncleBlock;
4+
5+
/**
6+
* ! NO DESCRIPTION !
7+
*
8+
* @author GoodforGod
9+
* @since 30.10.2018
10+
*/
11+
public class UncleBlockResponseTO extends BaseResponseTO {
12+
13+
private UncleBlock uncleBlock;
14+
15+
public UncleBlock getUncleBlock() {
16+
return uncleBlock;
17+
}
18+
}

0 commit comments

Comments
 (0)