BAEL-1461 refactored
This commit is contained in:
parent
21bd180c1c
commit
594b6dda12
|
@ -1,4 +1,6 @@
|
||||||
## EthereumJ
|
## Ethereum
|
||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
- [Introduction to EthereumJ](http://www.baeldung.com/ethereumj)
|
- [Introduction to EthereumJ](http://www.baeldung.com/ethereumj)
|
||||||
|
- [Lightweight Web3](http://www.baeldung.com/lightweight-web3/)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
## Web3j
|
## Ethereum
|
||||||
|
|
||||||
### Relevant Articles:
|
### Relevant Articles:
|
||||||
|
- [Introduction to EthereumJ](http://www.baeldung.com/ethereumj)
|
||||||
- [Lightweight Web3](http://www.baeldung.com/lightweight-web3/)
|
- [Lightweight Web3](http://www.baeldung.com/lightweight-web3/)
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<project
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung.ethereumj</groupId>
|
<groupId>com.baeldung.ethereumj</groupId>
|
||||||
<artifactId>ethereumj</artifactId>
|
<artifactId>ethereumj</artifactId>
|
||||||
|
@ -11,9 +13,18 @@
|
||||||
<artifactId>parent-boot-5</artifactId>
|
<artifactId>parent-boot-5</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<relativePath>../parent-boot-5</relativePath>
|
<relativePath>../../parent-boot-5</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<tomcat.version>8.5.4</tomcat.version>
|
||||||
|
<ethereumj-core.version>1.5.0-RELEASE</ethereumj-core.version>
|
||||||
|
<web3j.core.version>3.3.1</web3j.core.version>
|
||||||
|
<jackson-databind.version>2.5.0</jackson-databind.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>Ethereum</id>
|
<id>Ethereum</id>
|
||||||
|
@ -23,7 +34,6 @@
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Spring Boot Dependencies -->
|
<!-- Spring Boot Dependencies -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
@ -33,28 +43,24 @@
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Unit Testing -->
|
<!-- Unit Testing -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Ethereum -->
|
<!-- Ethereum -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.ethereum</groupId>
|
<groupId>org.ethereum</groupId>
|
||||||
<artifactId>ethereumj-core</artifactId>
|
<artifactId>ethereumj-core</artifactId>
|
||||||
<version>1.5.0-RELEASE</version>
|
<version>${ethereumj-core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- Web3j -->
|
<!-- Web3j -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.web3j</groupId>
|
<groupId>org.web3j</groupId>
|
||||||
<artifactId>core</artifactId>
|
<artifactId>core</artifactId>
|
||||||
<version>3.3.1</version>
|
<version>${web3j.core.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JSTL/JSP -->
|
<!-- JSTL/JSP -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.servlet</groupId>
|
<groupId>javax.servlet</groupId>
|
||||||
|
@ -63,12 +69,20 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
<artifactId>jackson-databind</artifactId>
|
<artifactId>jackson-databind</artifactId>
|
||||||
<version>2.5.0</version>
|
<version>${jackson-databind.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
@ -77,40 +91,4 @@
|
||||||
<finalName>ethereumj</finalName>
|
<finalName>ethereumj</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<profiles>
|
|
||||||
<profile>
|
|
||||||
<id>integration</id>
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>integration-test</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>test</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<excludes>
|
|
||||||
<exclude>none</exclude>
|
|
||||||
</excludes>
|
|
||||||
<includes>
|
|
||||||
<include>*/EthControllerTestOne.java</include>
|
|
||||||
</includes>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
</profile>
|
|
||||||
</profiles>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
<tomcat.version>8.5.4</tomcat.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung.ethereum</groupId>
|
||||||
|
<artifactId>ethereum</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<name>ethereum</name>
|
||||||
|
|
||||||
|
</project>
|
|
@ -8,7 +8,7 @@
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<name>web3j</name>
|
<name>web3j</name>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<hamcrest.version>1.3</hamcrest.version>
|
<hamcrest.version>1.3</hamcrest.version>
|
||||||
<jackson.version>2.9.3</jackson.version>
|
<jackson.version>2.9.3</jackson.version>
|
||||||
<javax-jsp.version>2.3.1</javax-jsp.version>
|
<javax-jsp.version>2.3.1</javax-jsp.version>
|
|
@ -47,51 +47,46 @@ public class Web3Service {
|
||||||
return "0x" + binary;
|
return "0x" + binary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<EthBlockNumber> getBlockNumber() {
|
public CompletableFuture<EthBlockNumber> getBlockNumber() {
|
||||||
EthBlockNumber result = new EthBlockNumber();
|
EthBlockNumber result = new EthBlockNumber();
|
||||||
try {
|
try {
|
||||||
this.web3j.ethBlockNumber().sendAsync().thenApply(r -> r.getBlockNumber());
|
result = this.web3j.ethBlockNumber().sendAsync().get();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(GENERIC_EXCEPTION);
|
System.out.println(GENERIC_EXCEPTION);
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(result);
|
return CompletableFuture.completedFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<EthAccounts> getEthAccounts() {
|
public CompletableFuture<EthAccounts> getEthAccounts() {
|
||||||
EthAccounts result = new EthAccounts();
|
EthAccounts result = new EthAccounts();
|
||||||
try {
|
try {
|
||||||
this.web3j.ethAccounts().sendAsync().thenApply(r -> r.getAccounts());
|
result = this.web3j.ethAccounts().sendAsync().get();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(GENERIC_EXCEPTION);
|
System.out.println(GENERIC_EXCEPTION);
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(result);
|
return CompletableFuture.completedFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<EthGetTransactionCount> getTransactionCount() {
|
public CompletableFuture<EthGetTransactionCount> getTransactionCount() {
|
||||||
EthGetTransactionCount result = new EthGetTransactionCount();
|
EthGetTransactionCount result = new EthGetTransactionCount();
|
||||||
try {
|
try {
|
||||||
this.web3j.ethGetTransactionCount(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().thenApply(r -> r.getTransactionCount());
|
result = this.web3j.ethGetTransactionCount(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().get();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(GENERIC_EXCEPTION);
|
System.out.println(GENERIC_EXCEPTION);
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(result);
|
return CompletableFuture.completedFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<EthGetBalance> getEthBalance() {
|
public CompletableFuture<EthGetBalance> getEthBalance() {
|
||||||
EthGetBalance result = new EthGetBalance();
|
EthGetBalance result = new EthGetBalance();
|
||||||
try {
|
try {
|
||||||
this.web3j.ethGetBalance(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().thenApply(r -> r.getBalance());
|
result = this.web3j.ethGetBalance(DEFAULT_ADDRESS, DefaultBlockParameter.valueOf("latest")).sendAsync().get();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
System.out.println(GENERIC_EXCEPTION);
|
System.out.println(GENERIC_EXCEPTION);
|
||||||
}
|
}
|
||||||
return CompletableFuture.completedFuture(result);
|
return CompletableFuture.completedFuture(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
|
||||||
public CompletableFuture<String> fromScratchContractExample() {
|
public CompletableFuture<String> fromScratchContractExample() {
|
||||||
|
|
||||||
String contractAddress = "";
|
String contractAddress = "";
|
3
pom.xml
3
pom.xml
|
@ -73,8 +73,7 @@
|
||||||
<module>deltaspike</module>
|
<module>deltaspike</module>
|
||||||
<module>dozer</module>
|
<module>dozer</module>
|
||||||
|
|
||||||
<module>ethereumj</module>
|
<module>ethereum</module>
|
||||||
<module>web3j</module>
|
|
||||||
|
|
||||||
<!--<module>ejb</module>-->
|
<!--<module>ejb</module>-->
|
||||||
|
|
||||||
|
|
|
@ -285,8 +285,6 @@
|
||||||
<commons-lang.version>2.4</commons-lang.version>
|
<commons-lang.version>2.4</commons-lang.version>
|
||||||
<java-version>1.8</java-version>
|
<java-version>1.8</java-version>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- maven plugins -->
|
<!-- maven plugins -->
|
||||||
<maven-jibx-plugin.version>1.3.1</maven-jibx-plugin.version>
|
<maven-jibx-plugin.version>1.3.1</maven-jibx-plugin.version>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue