Skip to content

Commit

Permalink
Merge branch 'master' into fix_codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
gtebrean committed Aug 18, 2023
2 parents 6d8048b + 5cda8b0 commit de53daf
Show file tree
Hide file tree
Showing 42 changed files with 3,358 additions and 70 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
registry.password: ${{ secrets.REGISTRY_PASSWORD }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand All @@ -33,10 +33,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: "CodeQL"

on:
push:
branches: [ 'master' ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ 'master' ]
schedule:
- cron: '35 2 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'java' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Use only 'java' to analyze code written in Java, Kotlin or both
# Use only 'javascript' to analyze code written in JavaScript, TypeScript or both
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality

- name: Build
run: ./gradlew check jacocoRootTestReport

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
with:
category: "/language:${{matrix.language}}"
4 changes: 2 additions & 2 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
propagate_failure: true
trigger_workflow: true
wait_workflow: true
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 17
- name: Cache Gradle packages
uses: actions/cache@v2
with:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Java:
<dependency>
<groupId>org.web3j</groupId>
<artifactId>core</artifactId>
<version>4.9.8</version>
<version>4.10.2</version>
</dependency>
```

Expand All @@ -130,7 +130,7 @@ Gradle
Java:

```groovy
implementation ('org.web3j:core:4.9.8')
implementation ('org.web3j:core:4.10.0')
```

Android:
Expand Down
23 changes: 22 additions & 1 deletion abi/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
plugins {
id 'java-library'
}

description 'Ethereum Application Binary Interface (ABI) for working with smart contracts'

dependencies {
compile project(':utils')
api project(':utils')
}

tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","test") }
tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") }
tasks.named("jacocoRootTestReport").configure { dependsOn("compileJava","compileTestJava","javadoc","test", "spotlessGroovyGradle", "spotlessKotlin","spotlessJava") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":besu:compileJava",":besu:compileTestJava",":besu:javadoc",":besu:test", ":besu:spotlessGroovyGradle", ":besu:spotlessJava",":besu:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":test",":spotlessGroovyGradle",":spotlessJava",":spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":codegen:compileJava",":codegen:compileTestJava",":codegen:javadoc",":codegen:test",":codegen:processTestResources",":codegen:spotlessGroovyGradle", ":codegen:spotlessJava",":codegen:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":contracts:compileJava",":contracts:javadoc",":contracts:test",":contracts:processResources",":contracts:spotlessGroovyGradle", ":contracts:spotlessJava",":contracts:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":core:javadoc",":core:test",":core:spotlessGroovyGradle", ":core:spotlessJava",":core:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":crypto:javadoc",":crypto:test",":crypto:spotlessGroovyGradle", ":crypto:spotlessJava",":crypto:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":eea:compileTestJava",":eea:javadoc",":eea:test",":eea:spotlessGroovyGradle", ":eea:spotlessJava",":eea:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":geth:compileJava",":geth:compileTestJava",":geth:javadoc",":geth:test",":geth:spotlessGroovyGradle", ":geth:spotlessJava",":geth:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":hosted-providers:compileJava",":hosted-providers:compileTestJava",":hosted-providers:javadoc",":hosted-providers:test",":hosted-providers:spotlessGroovyGradle", ":hosted-providers:spotlessJava",":hosted-providers:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":integration-tests:compileTestJava",":integration-tests:processTestResources",":integration-tests:spotlessGroovyGradle", ":integration-tests:spotlessJava",":integration-tests:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":parity:compileJava",":parity:compileTestJava",":parity:javadoc",":parity:test",":parity:spotlessGroovyGradle", ":parity:spotlessJava",":parity:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":rlp:compileTestJava",":rlp:javadoc",":rlp:test",":rlp:spotlessGroovyGradle", ":rlp:spotlessJava",":rlp:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":tuples:javadoc",":tuples:test",":tuples:spotlessGroovyGradle", ":tuples:spotlessJava",":tuples:spotlessKotlin") }
tasks.named("jacocoRootTestReport").configure { dependsOn(":utils:javadoc",":utils:test",":utils:spotlessGroovyGradle", ":utils:spotlessJava",":utils:spotlessKotlin") }
11 changes: 8 additions & 3 deletions besu/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@

plugins {
id 'java-library'
}
description 'Besu JSON-RPC API'

dependencies {
compile project(':eea')
testCompile project(path: ':core', configuration: 'testArtifacts')
api project(':eea')
testImplementation project(path: ':core', configuration: 'testArtifacts')
}

tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","test") }
tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") }
14 changes: 9 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {


ext {
bouncycastleVersion = '1.70'
bouncycastleVersion = '1.73'
jacksonVersion = '2.14.2'
javaPoetVersion = '1.7.0'
kotlinVersion = '1.3.72'
Expand All @@ -23,10 +23,11 @@ ext {
slf4jVersion = '1.7.30'
javaWebSocketVersion = '1.5.3'
picocliVersion = '3.0.0'
ensAdraffyVersion = '0.1.2'
// test dependencies
equalsverifierVersion = '3.5.5'
equalsverifierVersion = '3.14.1'
junitVersion = '5.5.2'
web3jUnitVersion = '4.9.7'
web3jUnitVersion = '4.10.1'
junitBenchmarkVersion = '0.7.2'
logbackVersion = '1.2.3'
mockitoJunitVersion = '3.1.0'
Expand Down Expand Up @@ -71,8 +72,8 @@ allprojects {
}

dependencies {
testCompile "org.junit.jupiter:junit-jupiter:$junitVersion"
testCompile "org.mockito:mockito-junit-jupiter:$mockitoJunitVersion"
testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion"
testImplementation "org.mockito:mockito-junit-jupiter:$mockitoJunitVersion"

configurations.all {
resolutionStrategy {
Expand All @@ -96,3 +97,6 @@ allprojects {
configure(subprojects.findAll { it.name != 'integration-tests' }) {
apply from: "$rootDir/gradle/jacoco/build.gradle"
}

tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle") }
tasks.named("spotlessKotlin").configure { dependsOn("spotlessJava", "spotlessGroovyGradle") }
7 changes: 5 additions & 2 deletions codegen/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
description 'web3j project code generators'

dependencies {
compile project(':core'),
implementation project(':core'),
"com.squareup:kotlinpoet:$kotlinPoetVersion",
"com.squareup:javapoet:$javaPoetVersion",
"info.picocli:picocli:$picocliVersion"
testCompile project(':core').sourceSets.test.output,
testImplementation project(':core').sourceSets.test.output,
"ch.qos.logback:logback-core:$logbackVersion",
"ch.qos.logback:logback-classic:$logbackVersion"
implementation("org.junit.platform:junit-platform-launcher:$junitPlatformLauncherVersion")
Expand Down Expand Up @@ -37,3 +37,6 @@ file("src/test/resources/solidity").listFiles().each { File file ->
test.dependsOn generateTask
}
}

tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","processTestResources","javadoc","test") }
tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") }
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.net.URL;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -47,13 +48,25 @@ public CompilerClassLoader(final File outputDir, final URL... urls) {

@Override
protected Class<?> findClass(final String name) throws ClassNotFoundException {
return compileClass(name)
.flatMap(this::readBytes)
.map(bytes -> defineClass(name, bytes, 0, bytes.length))
List<Class<?>> loadedClasses =
compileClass(name).stream()
.map(
classFile -> {
Optional<byte[]> bytes = readBytes(classFile);
return defineClass(
extractClassName(classFile.toString()),
bytes.get(),
0,
bytes.get().length);
})
.collect(Collectors.toList());
return loadedClasses.stream()
.filter(c -> c.getName().equals(name))
.findFirst()
.orElseThrow(() -> new ClassNotFoundException(name));
}

private Optional<File> compileClass(final String name) {
private List<File> compileClass(final String name) {

final String path = name.replace(".", File.separator);
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
Expand All @@ -79,7 +92,7 @@ private Optional<File> compileClass(final String name) {
}

if (!sourceFile.exists()) {
return Optional.empty();
return List.of();
}

final Iterable<? extends JavaFileObject> javaFileObjects =
Expand All @@ -93,8 +106,27 @@ private Optional<File> compileClass(final String name) {
final CompilationTask task =
compiler.getTask(null, null, System.err::println, options, null, javaFileObjects);

final File classFile = new File(outputDir, path + ".class");
return task.call() ? Optional.of(classFile) : Optional.empty();
if (task.call()) {
try {
return Files.walk(Paths.get(outputDir.getAbsoluteFile().toURI()))
.filter(Files::isRegularFile)
.filter(
filePath -> {
String fileName = extractClassName(filePath.toString());
return fileName.startsWith(name);
})
.map(Path::toFile)
.toList();
} catch (IOException e) {
throw new IllegalStateException("Unable to process compiled classes: ", e);
}
}
return List.of();
}

private String extractClassName(final String pathName) {
return pathName.substring(outputDir.toString().length() + 1, pathName.lastIndexOf("."))
.replaceAll("/", ".");
}

private String buildClassPath() {
Expand Down
6 changes: 4 additions & 2 deletions contracts/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
description 'web3j support for Ethereum Improvement Proposals (EIP\'s)'

dependencies {
compile project(':core')
testCompile project(path: ':core', configuration: 'testArtifacts')
implementation project(':core')
testImplementation project(path: ':core', configuration: 'testArtifacts')
}
tasks.named("spotlessJava").configure { dependsOn("compileJava","javadoc","processResources","spotlessGroovyGradle") }
tasks.named("spotlessKotlin").configure { dependsOn("compileJava","javadoc","processResources","spotlessJava","spotlessGroovyGradle") }
15 changes: 11 additions & 4 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import java.text.SimpleDateFormat

apply plugin: 'org.ajoberstar.git-publish'
plugins {
id 'java-library'
id 'org.ajoberstar.git-publish'
}


description 'web3j is a lightweight Java library for integration with Ethereum clients'

dependencies {
compile project(':abi'),
api project(':abi'),
project(':crypto'),
project(':tuples'),
"com.github.jnr:jnr-unixsocket:$jnr_unixsocketVersion",
Expand All @@ -15,8 +18,9 @@ dependencies {
"io.reactivex.rxjava2:rxjava:$rxjavaVersion",
"org.java-websocket:Java-WebSocket:$javaWebSocketVersion",
"com.fasterxml.jackson.core:jackson-databind:$jacksonVersion",
"org.slf4j:slf4j-api:$slf4jVersion"
testCompile project(path: ':crypto', configuration: 'testArtifacts'),
"org.slf4j:slf4j-api:$slf4jVersion",
"io.github.adraffy:ens-normalize:$ensAdraffyVersion"
testImplementation project(path: ':crypto', configuration: 'testArtifacts'),
"nl.jqno.equalsverifier:equalsverifier:$equalsverifierVersion",
"ch.qos.logback:logback-classic:$logbackVersion"
}
Expand Down Expand Up @@ -78,3 +82,6 @@ classes { dependsOn createProperties }
configurations { testArtifacts.extendsFrom testRuntime }

artifacts { testArtifacts testsJar }

tasks.named("spotlessJava").configure { dependsOn("compileJava", "compileTestJava", "processResources", "processTestResources", "spotlessGroovyGradle","javadoc","test") }
tasks.named("spotlessKotlin").configure { dependsOn("compileJava", "compileTestJava", "processResources", "processTestResources","spotlessJava","spotlessGroovyGradle","javadoc","test") }
10 changes: 6 additions & 4 deletions core/src/main/java/org/web3j/ens/NameHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.IDN;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

import io.github.adraffy.ens.ENSNormalize;
import io.github.adraffy.ens.InvalidLabelException;

import org.web3j.crypto.Hash;
import org.web3j.utils.Numeric;

Expand Down Expand Up @@ -58,16 +60,16 @@ private static byte[] nameHash(String[] labels) {

/**
* Normalise ENS name as per the <a
* href="http://docs.ens.domains/en/latest/implementers.html#normalising-and-validating-names">specification</a>.
* href="https://docs.ens.domains/ens-improvement-proposals/ensip-15-normalization-standard">specification</a>.
*
* @param ensName our user input ENS name
* @return normalised ens name
* @throws EnsResolutionException if the name cannot be normalised
*/
public static String normalise(String ensName) {
try {
return IDN.toASCII(ensName, IDN.USE_STD3_ASCII_RULES).toLowerCase();
} catch (IllegalArgumentException e) {
return ENSNormalize.ENSIP15.normalize(ensName);
} catch (InvalidLabelException e) {
throw new EnsResolutionException("Invalid ENS name provided: " + ensName);
}
}
Expand Down
Loading

0 comments on commit de53daf

Please sign in to comment.