Skip to content

Commit

Permalink
Merge pull request #2 from piomin/renovate/spring-boot
Browse files Browse the repository at this point in the history
Update dependency org.springframework.boot:spring-boot-starter-parent to v2.7.18
  • Loading branch information
piomin authored Feb 23, 2024
2 parents 3141e12 + 6b607a3 commit 873a653
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 390 deletions.
41 changes: 31 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,48 @@
version: 2.1
version: '2.1'

jobs:
analyze:
docker:
- image: 'cimg/openjdk:11.0'
- image: 'cimg/openjdk:21.0.2'
steps:
- checkout
- run:
name: Analyze on SonarCloud
command: mvn verify sonar:sonar

executors:
jdk:
docker:
- image: 'cimg/openjdk:11.0'
command: mvn web3j:generate-sources verify sonar:sonar -DskipTests
test:
executor: machine_executor_amd64
steps:
- checkout
- run:
name: Install OpenJDK 21
command: |
java -version
sudo apt-get update && sudo apt-get install openjdk-21-jdk
sudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/java-21-openjdk-amd64/bin/javac
java -version
export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64
- run:
name: Generate Sources
command: mvn web3j:generate-sources
- run:
name: Maven Tests
command: mvn test

orbs:
maven: circleci/[email protected]

executors:
machine_executor_amd64:
machine:
image: ubuntu-2204:2023.10.1
environment:
architecture: "amd64"
platform: "linux/amd64"

workflows:
maven_test:
jobs:
- maven/test:
executor: jdk
- test
- analyze:
context: SonarCloud
56 changes: 56 additions & 0 deletions contract-service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,67 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>${web3j.version}</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>tuples</artifactId>
<version>${web3j.version}</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>abi</artifactId>
<version>${web3j.version}</version>
</dependency>
<dependency>
<groupId>org.web3j</groupId>
<artifactId>crypto</artifactId>
<version>${web3j.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/generated</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
@SpringBootApplication
public class ContractApp {

private static final Logger LOGGER = LoggerFactory.getLogger(ContractApp.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ContractApp.class);

@Autowired
Web3j web3j;
@Autowired
ContractService service;

public static void main(String[] args) {
SpringApplication.run(ContractApp.class, args);
}

@PostConstruct
public void listen() {
web3j.transactionObservable().subscribe(tx -> {
if (tx.getTo() != null && tx.getTo().equals(service.getOwnerAccount())) {
LOGGER.info("New tx: id={}, block={}, from={}, to={}, value={}", tx.getHash(), tx.getBlockHash(), tx.getFrom(), tx.getTo(), tx.getValue().intValue());
service.processContracts(tx.getValue().longValue());
} else {
LOGGER.info("Not matched: id={}, to={}", tx.getHash(), tx.getTo());
}
});
web3j.transactionFlowable().subscribe(tx -> {
if (tx.getTo() != null && tx.getTo().equals(service.getOwnerAccount())) {
LOGGER.info("New tx: id={}, block={}, from={}, to={}, value={}", tx.getHash(), tx.getBlockHash(), tx.getFrom(), tx.getTo(), tx.getValue().intValue());
service.processContracts(tx.getValue().longValue());
} else {
LOGGER.info("Not matched: id={}, to={}", tx.getHash(), tx.getTo());
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class ContractController {

@Autowired
ContractService service;

@GetMapping("/owner")
public String getOwnerAccount() {
return service.getOwnerAccount();
return service.getOwnerAccount();
}

@PostMapping
public Contract createContract(@RequestBody Contract newContract) throws Exception {
return service.createContract(newContract);
return service.createContract(newContract);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@

public class Contract {

private int fee;
private String receiver;
private String address;
private int fee;
private String receiver;
private String address;

public int getFee() {
return fee;
}
public int getFee() {
return fee;
}

public void setFee(int fee) {
this.fee = fee;
}
public void setFee(int fee) {
this.fee = fee;
}

public String getReceiver() {
return receiver;
}
public String getReceiver() {
return receiver;
}

public void setReceiver(String receiver) {
this.receiver = receiver;
}
public void setReceiver(String receiver) {
this.receiver = receiver;
}

public String getAddress() {
return address;
}
public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}
public void setAddress(String address) {
this.address = address;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@

public class Transaction {

private String contract;
private long amount;
private String contract;
private long amount;

public String getContract() {
return contract;
}
public String getContract() {
return contract;
}

public void setContract(String contract) {
this.contract = contract;
}
public void setContract(String contract) {
this.contract = contract;
}

public long getAmount() {
return amount;
}
public long getAmount() {
return amount;
}

public void setAmount(long amount) {
this.amount = amount;
}
public void setAmount(long amount) {
this.amount = amount;
}

}
Loading

0 comments on commit 873a653

Please sign in to comment.