diff --git a/CHANGELOG.md b/CHANGELOG.md index 09c689c7a2..3b91d8d744 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. -# [4.11.4]() (Upcoming) +# [4.12.0]() (Upcoming) ### Bug Fixes @@ -15,7 +15,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline ### BREAKING CHANGES -* +* Upgrade gradle to 8.7 and remove Consensys Repo dependency [#2057](https://github.com/hyperledger/web3j/pull/2057) # [4.11.3](https://github.com/hyperledger/web3j/releases/tag/v4.11.3) (2024-05-01) diff --git a/abi/build.gradle b/abi/build.gradle index 8f13019b70..e03e22a521 100644 --- a/abi/build.gradle +++ b/abi/build.gradle @@ -8,5 +8,10 @@ dependencies { 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("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/abi/src/main/java/org/web3j/abi/FunctionEncoder.java b/abi/src/main/java/org/web3j/abi/FunctionEncoder.java index a4cd278a7f..01a156fcd2 100644 --- a/abi/src/main/java/org/web3j/abi/FunctionEncoder.java +++ b/abi/src/main/java/org/web3j/abi/FunctionEncoder.java @@ -70,8 +70,11 @@ public static Function makeFunction( List solidityInputTypes, List arguments, List solidityOutputTypes) - throws ClassNotFoundException, NoSuchMethodException, InstantiationException, - IllegalAccessException, InvocationTargetException { + throws ClassNotFoundException, + NoSuchMethodException, + InstantiationException, + IllegalAccessException, + InvocationTargetException { List encodedInput = new ArrayList<>(); Iterator argit = arguments.iterator(); for (String st : solidityInputTypes) { @@ -88,7 +91,9 @@ public static Function makeFunction( protected abstract String encodeParameters(List parameters); - /** @param methodId Callback selector / Abi method Id (Hex format) */ + /** + * @param methodId Callback selector / Abi method Id (Hex format) + */ protected abstract String encodeWithSelector( final String methodId, final List parameters); diff --git a/abi/src/main/java/org/web3j/abi/TypeDecoder.java b/abi/src/main/java/org/web3j/abi/TypeDecoder.java index da07c46e37..e24d8f01cf 100644 --- a/abi/src/main/java/org/web3j/abi/TypeDecoder.java +++ b/abi/src/main/java/org/web3j/abi/TypeDecoder.java @@ -71,14 +71,20 @@ public class TypeDecoder { static final int MAX_BYTE_LENGTH_FOR_HEX_STRING = Type.MAX_BYTE_LENGTH << 1; public static Type instantiateType(String solidityType, Object value) - throws InvocationTargetException, NoSuchMethodException, InstantiationException, - IllegalAccessException, ClassNotFoundException { + throws InvocationTargetException, + NoSuchMethodException, + InstantiationException, + IllegalAccessException, + ClassNotFoundException { return instantiateType(makeTypeReference(solidityType), value); } public static Type instantiateType(TypeReference ref, Object value) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, - InstantiationException, ClassNotFoundException { + throws NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + InstantiationException, + ClassNotFoundException { Class rc = ref.getClassType(); if (Array.class.isAssignableFrom(rc)) { return instantiateArrayType(ref, value); @@ -183,8 +189,11 @@ static int getTypeLength(Class type) { } static Type instantiateArrayType(TypeReference ref, Object value) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, - InstantiationException, ClassNotFoundException { + throws NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + InstantiationException, + ClassNotFoundException { List values; if (value instanceof List) { values = (List) value; @@ -218,8 +227,11 @@ static Type instantiateArrayType(TypeReference ref, Object value) } static Type instantiateAtomicType(Class referenceClass, Object value) - throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, - InstantiationException, ClassNotFoundException { + throws NoSuchMethodException, + IllegalAccessException, + InvocationTargetException, + InstantiationException, + ClassNotFoundException { Object constructorArg = null; if (NumericType.class.isAssignableFrom(referenceClass)) { constructorArg = asBigInteger(value); diff --git a/abi/src/test/java/org/web3j/abi/DefaultFunctionEncoderTest.java b/abi/src/test/java/org/web3j/abi/DefaultFunctionEncoderTest.java index e07631a651..d5abf6edcc 100644 --- a/abi/src/test/java/org/web3j/abi/DefaultFunctionEncoderTest.java +++ b/abi/src/test/java/org/web3j/abi/DefaultFunctionEncoderTest.java @@ -800,8 +800,11 @@ public void testABIv2DynamicArrayEncode() { @Test public void testMakeFunction() - throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, - InstantiationException, IllegalAccessException { + throws ClassNotFoundException, + NoSuchMethodException, + InvocationTargetException, + InstantiationException, + IllegalAccessException { Function expectedFunction = new Function( diff --git a/besu/build.gradle b/besu/build.gradle index a4e5a9183a..c0d86721e4 100644 --- a/besu/build.gradle +++ b/besu/build.gradle @@ -8,5 +8,10 @@ dependencies { 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") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/build.gradle b/build.gradle index b1dd8da6c5..c4ad35db88 100644 --- a/build.gradle +++ b/build.gradle @@ -1,38 +1,38 @@ plugins { id 'java' id 'idea' - id 'org.sonarqube' version '3.4.0.2513' + id 'org.sonarqube' version '5.0.0.4638' id 'jacoco' - id 'com.diffplug.gradle.spotless' version '4.5.1' - id 'io.codearte.nexus-staging' version '0.22.0' + id 'com.diffplug.spotless' version '6.25.0' + id 'io.codearte.nexus-staging' version '0.30.0' id 'de.marcphilipp.nexus-publish' version '0.4.0' - id 'de.undercouch.download' version '4.1.1' + id 'de.undercouch.download' version '4.1.2' id 'org.ajoberstar.git-publish' version '3.0.1' } ext { - bouncycastleVersion = '1.73' - jacksonVersion = '2.14.2' - javaPoetVersion = '1.7.0' - kotlinVersion = '1.3.72' - kotlinPoetVersion = '1.5.0' - jnr_unixsocketVersion = '0.38.17' - okhttpVersion = '4.9.0' - rxjavaVersion = '2.2.2' - slf4jVersion = '2.0.11' - javaWebSocketVersion = '1.5.3' - picocliVersion = '3.0.0' - ensAdraffyVersion = '0.1.2' - kzg4844Version = '0.8.0' + bouncycastleVersion = '1.78.1' + jacksonVersion = '2.17.1' + javaPoetVersion = '1.13.0' + kotlinVersion = '1.9.24' + kotlinPoetVersion = '1.16.0' + jnr_unixsocketVersion = '0.38.22' + okhttpVersion = '4.12.0' + rxjavaVersion = '2.2.21' + slf4jVersion = '2.0.13' + javaWebSocketVersion = '1.5.6' + picocliVersion = '4.7.6' + ensAdraffyVersion = '0.2.0' + kzg4844Version = '1.0.0' tuweniVersion = '2.4.2' // test dependencies - equalsverifierVersion = '3.14.1' + equalsverifierVersion = '3.16.1' junitVersion = '5.5.2' web3jUnitVersion = '4.11.3' junitBenchmarkVersion = '0.7.2' - logbackVersion = '1.4.14' + logbackVersion = '1.5.6' mockitoJunitVersion = '3.1.0' junitPlatformLauncherVersion = '1.5.2' } @@ -74,10 +74,6 @@ allprojects { useJUnitPlatform() } - repositories { - maven { url "https://artifacts.consensys.net/public/maven/maven/" } - } - dependencies { testImplementation "org.junit.jupiter:junit-jupiter:$junitVersion" testImplementation "org.mockito:mockito-junit-jupiter:$mockitoJunitVersion" diff --git a/codegen/build.gradle b/codegen/build.gradle index 4880785a16..8df53fc28d 100644 --- a/codegen/build.gradle +++ b/codegen/build.gradle @@ -38,5 +38,10 @@ file("src/test/resources/solidity").listFiles().each { File file -> } } -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","processTestResources","javadoc","test") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/codegen/src/test/java/org/web3j/codegen/SolidityFunctionWrapperTest.java b/codegen/src/test/java/org/web3j/codegen/SolidityFunctionWrapperTest.java index da7ea382d5..156641638d 100644 --- a/codegen/src/test/java/org/web3j/codegen/SolidityFunctionWrapperTest.java +++ b/codegen/src/test/java/org/web3j/codegen/SolidityFunctionWrapperTest.java @@ -187,7 +187,8 @@ public void testBuildFunctionTransaction() throws Exception { MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(\n" + " FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" @@ -231,7 +232,8 @@ public void testBuildPayableFunctionTransaction() throws Exception { MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.math.BigInteger param, java.math.BigInteger weiValue) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.math.BigInteger param, java.math.BigInteger weiValue) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(\n" + " FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" @@ -256,14 +258,15 @@ public void testBuildFunctionConstantSingleValueReturn() throws Exception { MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference() {}));\n" + " return executeRemoteCallSingleValueReturn(function, java.math.BigInteger.class);\n" + "}\n"; - assertEquals(methodSpec.toString(), (expected)); + assertEquals((expected), methodSpec.toString()); } @Test @@ -280,7 +283,8 @@ public void testBuildFunctionConstantSingleValueRawListReturn() throws Exception MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference>() {}));\n" @@ -295,7 +299,7 @@ public void testBuildFunctionConstantSingleValueRawListReturn() throws Exception + " });\n" + "}\n"; - assertEquals(methodSpec.toString(), (expected)); + assertEquals((expected), methodSpec.toString()); } @Test @@ -312,7 +316,8 @@ public void testBuildFunctionConstantDynamicArrayRawListReturn() throws Exceptio MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.util.List param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.util.List param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.DynamicArray(\n" + " org.web3j.abi.datatypes.generated.Uint8.class,\n" @@ -329,7 +334,7 @@ public void testBuildFunctionConstantDynamicArrayRawListReturn() throws Exceptio + " });\n" + "}\n"; - assertEquals(methodSpec.toString(), (expected)); + assertEquals((expected), methodSpec.toString()); } @Test @@ -346,7 +351,8 @@ public void testBuildFunctionConstantMultiDynamicArrayRawListReturn() throws Exc MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall functionName(java.util.List> param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall functionName(\n" + + " java.util.List> param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.DynamicArray(\n" + " org.web3j.abi.datatypes.DynamicArray.class,\n" @@ -364,7 +370,7 @@ public void testBuildFunctionConstantMultiDynamicArrayRawListReturn() throws Exc + " });\n" + "}\n"; - assertEquals(methodSpec.toString(), (expected)); + assertEquals((expected), methodSpec.toString()); } @Test @@ -562,7 +568,9 @@ public void testBuildFunctionStructArrayParameterAndReturn() throws Exception { MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall, java.util.List, java.util.List, java.util.List, java.util.List>> idNarBarFooArrays(java.util.List a, java.util.List b, java.util.List c, java.util.List d, java.util.List e) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall, java.util.List, java.util.List, java.util.List, java.util.List>> idNarBarFooArrays(\n" + + " java.util.List a, java.util.List b, java.util.List c, java.util.List d,\n" + + " java.util.List e) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_IDNARBARFOOARRAYS, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.StaticArray3(\n" + " Nar.class,\n" @@ -583,7 +591,8 @@ public void testBuildFunctionStructArrayParameterAndReturn() throws Exception { + " return new org.web3j.protocol.core.RemoteFunctionCall, java.util.List, java.util.List, java.util.List, java.util.List>>(function,\n" + " new java.util.concurrent.Callable, java.util.List, java.util.List, java.util.List, java.util.List>>() {\n" + " @java.lang.Override\n" - + " public org.web3j.tuples.generated.Tuple5, java.util.List, java.util.List, java.util.List, java.util.List> call() throws java.lang.Exception {\n" + + " public org.web3j.tuples.generated.Tuple5, java.util.List, java.util.List, java.util.List, java.util.List> call(\n" + + " ) throws java.lang.Exception {\n" + " java.util.List results = executeCallMultipleValueReturn(function);\n" + " return new org.web3j.tuples.generated.Tuple5, java.util.List, java.util.List, java.util.List, java.util.List>(\n" + " convertToNative((java.util.List) results.get(0).getValue()), \n" @@ -632,7 +641,8 @@ public void testBuildFunctionConstantMultipleValueReturn() throws Exception { MethodSpec methodSpec = solidityFunctionWrapper.buildFunction(functionDefinition); String expected = - "public org.web3j.protocol.core.RemoteFunctionCall> functionName(java.math.BigInteger param1, java.math.BigInteger param2) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall> functionName(\n" + + " java.math.BigInteger param1, java.math.BigInteger param2) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param1), \n" + " new org.web3j.abi.datatypes.generated.Uint32(param2)), \n" @@ -640,7 +650,8 @@ public void testBuildFunctionConstantMultipleValueReturn() throws Exception { + " return new org.web3j.protocol.core.RemoteFunctionCall>(function,\n" + " new java.util.concurrent.Callable>() {\n" + " @java.lang.Override\n" - + " public org.web3j.tuples.generated.Tuple2 call() throws java.lang.Exception {\n" + + " public org.web3j.tuples.generated.Tuple2 call()\n" + + " throws java.lang.Exception {\n" + " java.util.List results = executeCallMultipleValueReturn(function);\n" + " return new org.web3j.tuples.generated.Tuple2(\n" + " (java.math.BigInteger) results.get(0).getValue(), \n" @@ -649,7 +660,7 @@ public void testBuildFunctionConstantMultipleValueReturn() throws Exception { + " });\n" + "}\n"; - assertEquals(methodSpec.toString(), (expected)); + assertEquals((expected), methodSpec.toString()); } @Test @@ -680,7 +691,8 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception { "class testClass {\n" + " public static final org.web3j.abi.datatypes.Event TRANSFER_EVENT = new org.web3j.abi.datatypes.Event(\"Transfer\", \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference() {}, new org.web3j.abi.TypeReference() {}));\n ;\n\n" - + " public static java.util.List getTransferEvents(org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + + " public static java.util.List getTransferEvents(\n" + + " org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + " java.util.List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);\n" + " java.util.ArrayList responses = new java.util.ArrayList(valueList.size());\n" + " for (org.web3j.tx.Contract.EventValuesWithLog eventValues : valueList) {\n" @@ -696,7 +708,8 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception { + " return responses;\n" + " }\n" + "\n" - + " public static TransferEventResponse getTransferEventFromLog(org.web3j.protocol.core.methods.response.Log log) {\n" + + " public static TransferEventResponse getTransferEventFromLog(\n" + + " org.web3j.protocol.core.methods.response.Log log) {\n" + " org.web3j.tx.Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TRANSFER_EVENT, log);\n" + " TransferEventResponse typedResponse = new TransferEventResponse();\n" + " typedResponse.log = log;\n" @@ -708,11 +721,14 @@ public void testBuildEventConstantMultipleValueReturn() throws Exception { + " return typedResponse;\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + " return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log));\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.DefaultBlockParameter startBlock,\n" + + " org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + " org.web3j.protocol.core.methods.request.EthFilter filter = new org.web3j.protocol.core.methods.request.EthFilter(startBlock, endBlock, getContractAddress());\n" + " filter.addSingleTopic(org.web3j.abi.EventEncoder.encode(TRANSFER_EVENT));\n" + " return transferEventFlowable(filter);\n" @@ -763,7 +779,8 @@ public void testBuildEventWithNamedAndNoNamedParameters() throws Exception { "class testClass {\n" + " public static final org.web3j.abi.datatypes.Event TRANSFER_EVENT = new org.web3j.abi.datatypes.Event(\"Transfer\", \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference(true) {}, new org.web3j.abi.TypeReference() {}, new org.web3j.abi.TypeReference() {}, new org.web3j.abi.TypeReference() {}));\n ;\n\n" - + " public static java.util.List getTransferEvents(org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + + " public static java.util.List getTransferEvents(\n" + + " org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + " java.util.List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);\n" + " java.util.ArrayList responses = new java.util.ArrayList(valueList.size());\n" + " for (org.web3j.tx.Contract.EventValuesWithLog eventValues : valueList) {\n" @@ -780,7 +797,8 @@ public void testBuildEventWithNamedAndNoNamedParameters() throws Exception { + " return responses;\n" + " }\n" + "\n" - + " public static TransferEventResponse getTransferEventFromLog(org.web3j.protocol.core.methods.response.Log log) {\n" + + " public static TransferEventResponse getTransferEventFromLog(\n" + + " org.web3j.protocol.core.methods.response.Log log) {\n" + " org.web3j.tx.Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TRANSFER_EVENT, log);\n" + " TransferEventResponse typedResponse = new TransferEventResponse();\n" + " typedResponse.log = log;\n" @@ -793,11 +811,14 @@ public void testBuildEventWithNamedAndNoNamedParameters() throws Exception { + " return typedResponse;\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + " return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log));\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.DefaultBlockParameter startBlock,\n" + + " org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + " org.web3j.protocol.core.methods.request.EthFilter filter = new org.web3j.protocol.core.methods.request.EthFilter(startBlock, endBlock, getContractAddress());\n" + " filter.addSingleTopic(org.web3j.abi.EventEncoder.encode(TRANSFER_EVENT));\n" + " return transferEventFlowable(filter);\n" @@ -838,7 +859,8 @@ public void testBuildEventWithNativeList() throws Exception { "class testClass {\n" + " public static final org.web3j.abi.datatypes.Event TRANSFER_EVENT = new org.web3j.abi.datatypes.Event(\"Transfer\", \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference>() {}));\n ;\n\n" - + " public static java.util.List getTransferEvents(org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + + " public static java.util.List getTransferEvents(\n" + + " org.web3j.protocol.core.methods.response.TransactionReceipt transactionReceipt) {\n" + " java.util.List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt);\n" + " java.util.ArrayList responses = new java.util.ArrayList(valueList.size());\n" + " for (org.web3j.tx.Contract.EventValuesWithLog eventValues : valueList) {\n" @@ -850,7 +872,8 @@ public void testBuildEventWithNativeList() throws Exception { + " return responses;\n" + " }\n" + "\n" - + " public static TransferEventResponse getTransferEventFromLog(org.web3j.protocol.core.methods.response.Log log) {\n" + + " public static TransferEventResponse getTransferEventFromLog(\n" + + " org.web3j.protocol.core.methods.response.Log log) {\n" + " org.web3j.tx.Contract.EventValuesWithLog eventValues = staticExtractEventParametersWithLog(TRANSFER_EVENT, log);\n" + " TransferEventResponse typedResponse = new TransferEventResponse();\n" + " typedResponse.log = log;\n" @@ -858,11 +881,14 @@ public void testBuildEventWithNativeList() throws Exception { + " return typedResponse;\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.methods.request.EthFilter filter) {\n" + " return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log));\n" + " }\n" + "\n" - + " public io.reactivex.Flowable transferEventFlowable(org.web3j.protocol.core.DefaultBlockParameter startBlock, org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + + " public io.reactivex.Flowable transferEventFlowable(\n" + + " org.web3j.protocol.core.DefaultBlockParameter startBlock,\n" + + " org.web3j.protocol.core.DefaultBlockParameter endBlock) {\n" + " org.web3j.protocol.core.methods.request.EthFilter filter = new org.web3j.protocol.core.methods.request.EthFilter(startBlock, endBlock, getContractAddress());\n" + " filter.addSingleTopic(org.web3j.abi.EventEncoder.encode(TRANSFER_EVENT));\n" + " return transferEventFlowable(filter);\n" @@ -873,7 +899,7 @@ public void testBuildEventWithNativeList() throws Exception { + " }\n" + "}\n"; - assertEquals(builder.build().toString(), (expected)); + assertEquals((expected), builder.build().toString()); } @Test @@ -915,7 +941,8 @@ public void testBuildFunctionTransactionAndCall() throws Exception { solidityFunctionWrapperBoth.buildFunctions(functionDefinition); String expectedSend = - "public org.web3j.protocol.core.RemoteFunctionCall send_functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall send_functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(\n" + " FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" @@ -924,7 +951,8 @@ public void testBuildFunctionTransactionAndCall() throws Exception { + "}\n"; String expectedCall = - "public org.web3j.protocol.core.RemoteFunctionCall call_functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall call_functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference() {}));\n" @@ -951,7 +979,8 @@ public void testBuildFunctionConstantSingleValueReturnAndTransaction() throws Ex solidityFunctionWrapperBoth.buildFunctions(functionDefinition); String expectedCall = - "public org.web3j.protocol.core.RemoteFunctionCall call_functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall call_functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" + " java.util.Arrays.>asList(new org.web3j.abi.TypeReference() {}));\n" @@ -959,7 +988,8 @@ public void testBuildFunctionConstantSingleValueReturnAndTransaction() throws Ex + "}\n"; String expectedSend = - "public org.web3j.protocol.core.RemoteFunctionCall send_functionName(java.math.BigInteger param) {\n" + "public org.web3j.protocol.core.RemoteFunctionCall send_functionName(\n" + + " java.math.BigInteger param) {\n" + " final org.web3j.abi.datatypes.Function function = new org.web3j.abi.datatypes.Function(\n" + " FUNC_FUNCTIONNAME, \n" + " java.util.Arrays.asList(new org.web3j.abi.datatypes.generated.Uint8(param)), \n" diff --git a/codegen/src/test/java/org/web3j/codegen/unit/gen/java/MethodParserTest.java b/codegen/src/test/java/org/web3j/codegen/unit/gen/java/MethodParserTest.java index b339644393..9b3c41343f 100644 --- a/codegen/src/test/java/org/web3j/codegen/unit/gen/java/MethodParserTest.java +++ b/codegen/src/test/java/org/web3j/codegen/unit/gen/java/MethodParserTest.java @@ -36,7 +36,9 @@ public void testThatDeployMethodWasGenerated() { .getMethodSpec(); assertEquals( "@org.junit.jupiter.api.BeforeAll\n" - + "static void deploy(org.web3j.protocol.Web3j web3j, org.web3j.tx.TransactionManager transactionManager, org.web3j.tx.gas.ContractGasProvider contractGasProvider) throws java.lang.Exception {\n" + + "static void deploy(org.web3j.protocol.Web3j web3j,\n" + + " org.web3j.tx.TransactionManager transactionManager,\n" + + " org.web3j.tx.gas.ContractGasProvider contractGasProvider) throws java.lang.Exception {\n" + " greeter = org.web3j.test.contract.Greeter.deploy(web3j, transactionManager, contractGasProvider, \"REPLACE_ME\").send();\n" + "}\n", deployMethodSpec.toString()); diff --git a/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunParserTest.java b/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunParserTest.java index 97c1263f81..6b27117c94 100644 --- a/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunParserTest.java +++ b/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunParserTest.java @@ -35,10 +35,10 @@ public void testThatDeployMethodWasGenerated() { assertEquals( deployFunSpec.toString(), "@org.junit.jupiter.api.BeforeAll\n" - + "fun deploy(\n" + + "public fun deploy(\n" + " web3j: org.web3j.protocol.Web3j,\n" + " transactionManager: org.web3j.tx.TransactionManager,\n" - + " contractGasProvider: org.web3j.tx.gas.ContractGasProvider\n" + + " contractGasProvider: org.web3j.tx.gas.ContractGasProvider,\n" + ") {\n" + " greeter = org.web3j.test.contract.Greeter.deploy(web3j, transactionManager, contractGasProvider, \"REPLACE_ME\").send()\n" + "}\n"); @@ -53,7 +53,7 @@ public void testThatNewGreetingMethodWasGenerated() { assertEquals( deployFunSpec.toString(), "@org.junit.jupiter.api.Test\n" - + "fun newGreeting() {\n" + + "public fun newGreeting() {\n" + " val transactionReceiptVar = greeter.newGreeting(\"REPLACE_ME\").send()\n" + " org.junit.jupiter.api.Assertions.assertTrue(transactionReceiptVar.isStatusOK())\n" + "}\n"); diff --git a/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunSpecGeneratorTest.java b/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunSpecGeneratorTest.java index 0d3f1b848d..d4034aac99 100644 --- a/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunSpecGeneratorTest.java +++ b/codegen/src/test/java/org/web3j/codegen/unit/gen/kotlin/FunSpecGeneratorTest.java @@ -39,7 +39,7 @@ public void testGenerate() { assertEquals( generatedFunSpec.toString(), "@org.junit.jupiter.api.Test\n" - + "fun test() {\n" + + "public fun test() {\n" + " val hello = \"Hello how are you\"\n" + " val web3j = org.web3j.protocol.Web3j.build()\n" + "}\n"); diff --git a/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java b/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java index 25fc3ee406..90d765a370 100644 --- a/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java +++ b/codegen/src/test/resources/solidity/arraysinstruct/build/java/ArraysInStruct.java @@ -44,24 +44,29 @@ public class ArraysInStruct extends Contract { public static final String FUNC_CALLFUNCTION = "callFunction"; @Deprecated - protected ArraysInStruct(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected ArraysInStruct(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected ArraysInStruct(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected ArraysInStruct(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected ArraysInStruct(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected ArraysInStruct(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected ArraysInStruct(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected ArraysInStruct(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public RemoteFunctionCall callFunction(List bytesArrayField, Entity newEntity) { + public RemoteFunctionCall callFunction(List bytesArrayField, + Entity newEntity) { final Function function = new Function( FUNC_CALLFUNCTION, Arrays.asList(new org.web3j.abi.datatypes.DynamicArray( @@ -73,20 +78,24 @@ public RemoteFunctionCall callFunction(List bytesArr } @Deprecated - public static ArraysInStruct load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static ArraysInStruct load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { return new ArraysInStruct(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static ArraysInStruct load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static ArraysInStruct load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new ArraysInStruct(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static ArraysInStruct load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static ArraysInStruct load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return new ArraysInStruct(contractAddress, web3j, credentials, contractGasProvider); } - public static ArraysInStruct load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static ArraysInStruct load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new ArraysInStruct(contractAddress, web3j, transactionManager, contractGasProvider); } @@ -131,7 +140,16 @@ public static class Entity extends DynamicStruct { public List addressArrayFieldStatic; - public Entity(byte[] bytesField, byte[] extraData, List stringArrayField, List bytesArrayField, List bytes2ArrayField, List bytes32ArrayField, List unitArrayField, List unit256ArrayField, List boolField, List intArrayField, List addressArrayField, List stringArrayFieldStatic, List bytesArrayFieldStatic, List bytes2ArrayFieldStatic, List bytes32ArrayFieldStatic, List unitArrayFieldStatic, List unit256ArrayFieldStatic, List boolFieldStatic, List intArrayFieldStatic, List addressArrayFieldStatic) { + public Entity(byte[] bytesField, byte[] extraData, List stringArrayField, + List bytesArrayField, List bytes2ArrayField, + List bytes32ArrayField, List unitArrayField, + List unit256ArrayField, List boolField, + List intArrayField, List addressArrayField, + List stringArrayFieldStatic, List bytesArrayFieldStatic, + List bytes2ArrayFieldStatic, List bytes32ArrayFieldStatic, + List unitArrayFieldStatic, List unit256ArrayFieldStatic, + List boolFieldStatic, List intArrayFieldStatic, + List addressArrayFieldStatic) { super(new org.web3j.abi.datatypes.DynamicBytes(bytesField), new org.web3j.abi.datatypes.generated.Bytes32(extraData), new org.web3j.abi.datatypes.DynamicArray( @@ -210,7 +228,25 @@ public Entity(byte[] bytesField, byte[] extraData, List stringArrayField this.addressArrayFieldStatic = addressArrayFieldStatic; } - public Entity(DynamicBytes bytesField, Bytes32 extraData, @Parameterized(type = Utf8String.class) DynamicArray stringArrayField, @Parameterized(type = DynamicBytes.class) DynamicArray bytesArrayField, @Parameterized(type = Bytes2.class) DynamicArray bytes2ArrayField, @Parameterized(type = Bytes32.class) DynamicArray bytes32ArrayField, @Parameterized(type = Uint256.class) DynamicArray unitArrayField, @Parameterized(type = Uint256.class) DynamicArray unit256ArrayField, @Parameterized(type = Bool.class) DynamicArray boolField, @Parameterized(type = Int256.class) DynamicArray intArrayField, @Parameterized(type = Address.class) DynamicArray
addressArrayField, @Parameterized(type = Utf8String.class) StaticArray5 stringArrayFieldStatic, @Parameterized(type = DynamicBytes.class) StaticArray5 bytesArrayFieldStatic, @Parameterized(type = Bytes2.class) StaticArray5 bytes2ArrayFieldStatic, @Parameterized(type = Bytes32.class) StaticArray5 bytes32ArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5 unitArrayFieldStatic, @Parameterized(type = Uint256.class) StaticArray5 unit256ArrayFieldStatic, @Parameterized(type = Bool.class) StaticArray5 boolFieldStatic, @Parameterized(type = Int256.class) StaticArray5 intArrayFieldStatic, @Parameterized(type = Address.class) StaticArray5
addressArrayFieldStatic) { + public Entity(DynamicBytes bytesField, Bytes32 extraData, + @Parameterized(type = Utf8String.class) DynamicArray stringArrayField, + @Parameterized(type = DynamicBytes.class) DynamicArray bytesArrayField, + @Parameterized(type = Bytes2.class) DynamicArray bytes2ArrayField, + @Parameterized(type = Bytes32.class) DynamicArray bytes32ArrayField, + @Parameterized(type = Uint256.class) DynamicArray unitArrayField, + @Parameterized(type = Uint256.class) DynamicArray unit256ArrayField, + @Parameterized(type = Bool.class) DynamicArray boolField, + @Parameterized(type = Int256.class) DynamicArray intArrayField, + @Parameterized(type = Address.class) DynamicArray
addressArrayField, + @Parameterized(type = Utf8String.class) StaticArray5 stringArrayFieldStatic, + @Parameterized(type = DynamicBytes.class) StaticArray5 bytesArrayFieldStatic, + @Parameterized(type = Bytes2.class) StaticArray5 bytes2ArrayFieldStatic, + @Parameterized(type = Bytes32.class) StaticArray5 bytes32ArrayFieldStatic, + @Parameterized(type = Uint256.class) StaticArray5 unitArrayFieldStatic, + @Parameterized(type = Uint256.class) StaticArray5 unit256ArrayFieldStatic, + @Parameterized(type = Bool.class) StaticArray5 boolFieldStatic, + @Parameterized(type = Int256.class) StaticArray5 intArrayFieldStatic, + @Parameterized(type = Address.class) StaticArray5
addressArrayFieldStatic) { super(bytesField, extraData, stringArrayField, bytesArrayField, bytes2ArrayField, bytes32ArrayField, unitArrayField, unit256ArrayField, boolField, intArrayField, addressArrayField, stringArrayFieldStatic, bytesArrayFieldStatic, bytes2ArrayFieldStatic, bytes32ArrayFieldStatic, unitArrayFieldStatic, unit256ArrayFieldStatic, boolFieldStatic, intArrayFieldStatic, addressArrayFieldStatic); this.bytesField = bytesField.getValue(); this.extraData = extraData.getValue(); diff --git a/codegen/src/test/resources/solidity/eventparameters/build/java/EventParameters.java b/codegen/src/test/resources/solidity/eventparameters/build/java/EventParameters.java index cc49e84458..ae5206ced8 100644 --- a/codegen/src/test/resources/solidity/eventparameters/build/java/EventParameters.java +++ b/codegen/src/test/resources/solidity/eventparameters/build/java/EventParameters.java @@ -50,24 +50,29 @@ public class EventParameters extends Contract { ; @Deprecated - protected EventParameters(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected EventParameters(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected EventParameters(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected EventParameters(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected EventParameters(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected EventParameters(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected EventParameters(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected EventParameters(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } - public static List getTestEventEvents(TransactionReceipt transactionReceipt) { + public static List getTestEventEvents( + TransactionReceipt transactionReceipt) { List valueList = staticExtractEventParametersWithLog(TESTEVENT_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { @@ -97,7 +102,8 @@ public Flowable testEventEventFlowable(EthFilter filter) return web3j.ethLogFlowable(filter).map(log -> getTestEventEventFromLog(log)); } - public Flowable testEventEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable testEventEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(TESTEVENT_EVENT)); return testEventEventFlowable(filter); @@ -126,20 +132,24 @@ public RemoteFunctionCall testEvent() { } @Deprecated - public static EventParameters load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static EventParameters load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { return new EventParameters(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static EventParameters load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static EventParameters load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new EventParameters(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static EventParameters load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static EventParameters load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return new EventParameters(contractAddress, web3j, credentials, contractGasProvider); } - public static EventParameters load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static EventParameters load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new EventParameters(contractAddress, web3j, transactionManager, contractGasProvider); } diff --git a/codegen/src/test/resources/solidity/metacoin/build/java/MetaCoin.java b/codegen/src/test/resources/solidity/metacoin/build/java/MetaCoin.java index 865cec0434..d853b4a30c 100644 --- a/codegen/src/test/resources/solidity/metacoin/build/java/MetaCoin.java +++ b/codegen/src/test/resources/solidity/metacoin/build/java/MetaCoin.java @@ -52,20 +52,24 @@ public class MetaCoin extends Contract { ; @Deprecated - protected MetaCoin(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected MetaCoin(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected MetaCoin(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected MetaCoin(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected MetaCoin(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected MetaCoin(String contractAddress, Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected MetaCoin(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected MetaCoin(String contractAddress, Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } @@ -92,7 +96,8 @@ public RemoteFunctionCall getBalance(String addr) { return executeRemoteCallSingleValueReturn(function, BigInteger.class); } - public static List getTransferEvents(TransactionReceipt transactionReceipt) { + public static List getTransferEvents( + TransactionReceipt transactionReceipt) { List valueList = staticExtractEventParametersWithLog(TRANSFER_EVENT, transactionReceipt); ArrayList responses = new ArrayList(valueList.size()); for (Contract.EventValuesWithLog eventValues : valueList) { @@ -120,45 +125,54 @@ public Flowable transferEventFlowable(EthFilter filter) { return web3j.ethLogFlowable(filter).map(log -> getTransferEventFromLog(log)); } - public Flowable transferEventFlowable(DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) { + public Flowable transferEventFlowable(DefaultBlockParameter startBlock, + DefaultBlockParameter endBlock) { EthFilter filter = new EthFilter(startBlock, endBlock, getContractAddress()); filter.addSingleTopic(EventEncoder.encode(TRANSFER_EVENT)); return transferEventFlowable(filter); } @Deprecated - public static MetaCoin load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static MetaCoin load(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { return new MetaCoin(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static MetaCoin load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static MetaCoin load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new MetaCoin(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static MetaCoin load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static MetaCoin load(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return new MetaCoin(contractAddress, web3j, credentials, contractGasProvider); } - public static MetaCoin load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static MetaCoin load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new MetaCoin(contractAddress, web3j, transactionManager, contractGasProvider); } - public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { return deployRemoteCall(MetaCoin.class, web3j, credentials, contractGasProvider, getDeploymentBinary(), ""); } - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + ContractGasProvider contractGasProvider) { return deployRemoteCall(MetaCoin.class, web3j, transactionManager, contractGasProvider, getDeploymentBinary(), ""); } @Deprecated - public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static RemoteCall deploy(Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall(MetaCoin.class, web3j, credentials, gasPrice, gasLimit, getDeploymentBinary(), ""); } @Deprecated - public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, + BigInteger gasPrice, BigInteger gasLimit) { return deployRemoteCall(MetaCoin.class, web3j, transactionManager, gasPrice, gasLimit, getDeploymentBinary(), ""); } diff --git a/codegen/src/test/resources/solidity/onlyinarraystruct/build/java/OnlyInArrayStruct.java b/codegen/src/test/resources/solidity/onlyinarraystruct/build/java/OnlyInArrayStruct.java index 8675df94c3..1d4141b07f 100644 --- a/codegen/src/test/resources/solidity/onlyinarraystruct/build/java/OnlyInArrayStruct.java +++ b/codegen/src/test/resources/solidity/onlyinarraystruct/build/java/OnlyInArrayStruct.java @@ -37,20 +37,24 @@ public class OnlyInArrayStruct extends Contract { public static final String FUNC_SETFOO = "setFoo"; @Deprecated - protected OnlyInArrayStruct(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + protected OnlyInArrayStruct(String contractAddress, Web3j web3j, Credentials credentials, + BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit); } - protected OnlyInArrayStruct(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + protected OnlyInArrayStruct(String contractAddress, Web3j web3j, Credentials credentials, + ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, credentials, contractGasProvider); } @Deprecated - protected OnlyInArrayStruct(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + protected OnlyInArrayStruct(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - protected OnlyInArrayStruct(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + protected OnlyInArrayStruct(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider); } @@ -78,20 +82,24 @@ public RemoteFunctionCall setFoo(List foo) { } @Deprecated - public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { + public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, + Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) { return new OnlyInArrayStruct(contractAddress, web3j, credentials, gasPrice, gasLimit); } @Deprecated - public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { + public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) { return new OnlyInArrayStruct(contractAddress, web3j, transactionManager, gasPrice, gasLimit); } - public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) { + public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, + Credentials credentials, ContractGasProvider contractGasProvider) { return new OnlyInArrayStruct(contractAddress, web3j, credentials, contractGasProvider); } - public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) { + public static OnlyInArrayStruct load(String contractAddress, Web3j web3j, + TransactionManager transactionManager, ContractGasProvider contractGasProvider) { return new OnlyInArrayStruct(contractAddress, web3j, transactionManager, contractGasProvider); } diff --git a/core/build.gradle b/core/build.gradle index d1d65d51f7..72799e6bc7 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -54,7 +54,6 @@ gitPublish { if (ghToken) { repoUri = "https://github.com/${docsPath}.git" - } else { repoUri = "git@github.com:${docsPath}.git" } @@ -84,5 +83,10 @@ 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") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/core/src/main/java/org/web3j/crypto/WalletUtils.java b/core/src/main/java/org/web3j/crypto/WalletUtils.java index 0eae3cd8a9..9e210544bf 100644 --- a/core/src/main/java/org/web3j/crypto/WalletUtils.java +++ b/core/src/main/java/org/web3j/crypto/WalletUtils.java @@ -45,29 +45,41 @@ public class WalletUtils { } public static String generateFullNewWalletFile(String password, File destinationDirectory) - throws NoSuchAlgorithmException, NoSuchProviderException, - InvalidAlgorithmParameterException, CipherException, IOException { + throws NoSuchAlgorithmException, + NoSuchProviderException, + InvalidAlgorithmParameterException, + CipherException, + IOException { return generateNewWalletFile(password, destinationDirectory, true); } public static String generateLightNewWalletFile(String password, File destinationDirectory) - throws NoSuchAlgorithmException, NoSuchProviderException, - InvalidAlgorithmParameterException, CipherException, IOException { + throws NoSuchAlgorithmException, + NoSuchProviderException, + InvalidAlgorithmParameterException, + CipherException, + IOException { return generateNewWalletFile(password, destinationDirectory, false); } public static String generateNewWalletFile(String password, File destinationDirectory) - throws CipherException, InvalidAlgorithmParameterException, NoSuchAlgorithmException, - NoSuchProviderException, IOException { + throws CipherException, + InvalidAlgorithmParameterException, + NoSuchAlgorithmException, + NoSuchProviderException, + IOException { return generateFullNewWalletFile(password, destinationDirectory); } public static String generateNewWalletFile( String password, File destinationDirectory, boolean useFullScrypt) - throws CipherException, IOException, InvalidAlgorithmParameterException, - NoSuchAlgorithmException, NoSuchProviderException { + throws CipherException, + IOException, + InvalidAlgorithmParameterException, + NoSuchAlgorithmException, + NoSuchProviderException { ECKeyPair ecKeyPair = Keys.createEcKeyPair(); return generateWalletFile(password, ecKeyPair, destinationDirectory, useFullScrypt); diff --git a/crypto/build.gradle b/crypto/build.gradle index 0316098fa5..38bbb55485 100644 --- a/crypto/build.gradle +++ b/crypto/build.gradle @@ -19,5 +19,10 @@ configurations { testArtifacts.extendsFrom testRuntime } artifacts { testArtifacts testsJar } -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","processTestResources","test") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/crypto/src/main/java/org/web3j/crypto/Keys.java b/crypto/src/main/java/org/web3j/crypto/Keys.java index 812c2ecb8a..b29e4f9db5 100644 --- a/crypto/src/main/java/org/web3j/crypto/Keys.java +++ b/crypto/src/main/java/org/web3j/crypto/Keys.java @@ -57,13 +57,15 @@ private Keys() {} *

Private keys are encoded using X.509 */ static KeyPair createSecp256k1KeyPair() - throws NoSuchProviderException, NoSuchAlgorithmException, + throws NoSuchProviderException, + NoSuchAlgorithmException, InvalidAlgorithmParameterException { return createSecp256k1KeyPair(secureRandom()); } static KeyPair createSecp256k1KeyPair(SecureRandom random) - throws NoSuchProviderException, NoSuchAlgorithmException, + throws NoSuchProviderException, + NoSuchAlgorithmException, InvalidAlgorithmParameterException { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("ECDSA", "BC"); @@ -77,13 +79,15 @@ static KeyPair createSecp256k1KeyPair(SecureRandom random) } public static ECKeyPair createEcKeyPair() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, + throws InvalidAlgorithmParameterException, + NoSuchAlgorithmException, NoSuchProviderException { return createEcKeyPair(secureRandom()); } public static ECKeyPair createEcKeyPair(SecureRandom random) - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, + throws InvalidAlgorithmParameterException, + NoSuchAlgorithmException, NoSuchProviderException { KeyPair keyPair = createSecp256k1KeyPair(random); return ECKeyPair.create(keyPair); diff --git a/crypto/src/test/java/org/web3j/crypto/Secp256k1JWKTest.java b/crypto/src/test/java/org/web3j/crypto/Secp256k1JWKTest.java index dbbc5042fa..03723fbb87 100644 --- a/crypto/src/test/java/org/web3j/crypto/Secp256k1JWKTest.java +++ b/crypto/src/test/java/org/web3j/crypto/Secp256k1JWKTest.java @@ -50,7 +50,8 @@ public class Secp256k1JWKTest { @Test public void testPublicJWKCreation() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, + throws InvalidAlgorithmParameterException, + NoSuchAlgorithmException, NoSuchProviderException { KeyPair keyPair = Keys.createSecp256k1KeyPair(); BCECPublicKey publicKey = (BCECPublicKey) keyPair.getPublic(); @@ -61,7 +62,8 @@ public void testPublicJWKCreation() @Test public void testPrivateJWKCreation() - throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, + throws InvalidAlgorithmParameterException, + NoSuchAlgorithmException, NoSuchProviderException { KeyPair keyPair = Keys.createSecp256k1KeyPair(); BCECPublicKey publicKey = (BCECPublicKey) keyPair.getPublic(); diff --git a/eea/build.gradle b/eea/build.gradle index 4da3c7f8c1..9b2fd77e6c 100644 --- a/eea/build.gradle +++ b/eea/build.gradle @@ -10,5 +10,10 @@ dependencies { 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") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/geth/build.gradle b/geth/build.gradle index 8a66430316..8a8f36c639 100644 --- a/geth/build.gradle +++ b/geth/build.gradle @@ -6,5 +6,10 @@ dependencies { 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") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/gradle.properties b/gradle.properties index bcd971632d..fd3f1e11fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ group=org.web3j -version=4.11.4-SNAPSHOT +version=4.12.0-SNAPSHOT diff --git a/gradle/jacoco/build.gradle b/gradle/jacoco/build.gradle index 395abed1bd..f76ca1d1fb 100644 --- a/gradle/jacoco/build.gradle +++ b/gradle/jacoco/build.gradle @@ -14,9 +14,9 @@ jacocoTestReport { } dependsOn test reports { - xml.enabled true - html.enabled false - csv.enabled false + xml.required.set(true) + html.required.set(false) + csv.required.set(false) xml.destination file("${buildDir}/reports/jacoco.xml") } } @@ -29,6 +29,6 @@ sonarqube { } jacoco { - toolVersion = "0.8.8" + toolVersion = "0.8.10" } diff --git a/gradle/spotless/build.gradle b/gradle/spotless/build.gradle index 9dd2d47240..083e9dec24 100644 --- a/gradle/spotless/build.gradle +++ b/gradle/spotless/build.gradle @@ -1,5 +1,5 @@ -apply plugin: 'com.diffplug.gradle.spotless' +apply plugin: 'com.diffplug.spotless' apply plugin: "de.undercouch.download" task downloadJavaLicense(type: Download) { @@ -26,7 +26,7 @@ spotless { exclude '**/build/install/**' } removeUnusedImports() - googleJavaFormat("1.7").aosp() + googleJavaFormat("1.17.0").aosp() importOrder 'java', '', 'org.web3j', '\\#' trimTrailingWhitespace() endWithNewline() @@ -39,7 +39,7 @@ spotless { exclude '**/.gradle/**' exclude '**/build/install/**' } - ktlint('0.31.0') + ktlint('0.49.1') trimTrailingWhitespace() endWithNewline() licenseHeaderFile "$rootDir/gradle/spotless/java.license" diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 5c2d1cf016..e6441136f3 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0449293b48..b82aa23a4f 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,7 @@ - -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 83f2acfdc3..1aa94a4269 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,92 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=$((i+1)) + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" fi +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 24467a141f..7101f8e467 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail @@ -51,48 +55,36 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/hosted-providers/build.gradle b/hosted-providers/build.gradle index a8d0727dbc..d21bb35e0a 100644 --- a/hosted-providers/build.gradle +++ b/hosted-providers/build.gradle @@ -3,5 +3,10 @@ description 'web3j customisations for working with hosted web3 providers (Infura dependencies { implementation project(':core') } -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","test") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc", "test") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/integration-tests/build.gradle b/integration-tests/build.gradle index b313b03ad1..5e248171b7 100644 --- a/integration-tests/build.gradle +++ b/integration-tests/build.gradle @@ -9,10 +9,10 @@ repositories { maven { url "https://splunk.jfrog.io/splunk/ext-releases-local" } } ext { - besuPluginVersion = '23.7.0' - besuInternalVersion = '23.7.0' + besuPluginVersion = '24.1.1' + besuInternalVersion = '24.1.1' besuInternalCryptoVersion = '23.1.3' - besuCryptoDepVersion = '0.7.1' + besuCryptoDepVersion = '0.8.3' } def withoutAbi = { exclude group: 'org.web3j', module: 'abi' } diff --git a/integration-tests/src/test/java/org/web3j/protocol/besu/BesuPrivacyQuickstartIntegrationTest.java b/integration-tests/src/test/java/org/web3j/protocol/besu/BesuPrivacyQuickstartIntegrationTest.java index af6eb17b4d..8eeea3912b 100644 --- a/integration-tests/src/test/java/org/web3j/protocol/besu/BesuPrivacyQuickstartIntegrationTest.java +++ b/integration-tests/src/test/java/org/web3j/protocol/besu/BesuPrivacyQuickstartIntegrationTest.java @@ -258,8 +258,11 @@ public void privacyGroupContract() throws Exception { // Find the privacy group that was built by Alice from Bob's node final Base64String aliceBobGroupFromBobNode = - nodeBob.privFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)) - .send().getGroups().stream() + nodeBob + .privFindPrivacyGroup(Arrays.asList(ENCLAVE_KEY_ALICE, ENCLAVE_KEY_BOB)) + .send() + .getGroups() + .stream() .filter( g -> g.getName().equals("AliceBob") diff --git a/parity/build.gradle b/parity/build.gradle index 0a30184abf..039000994c 100644 --- a/parity/build.gradle +++ b/parity/build.gradle @@ -7,5 +7,10 @@ dependencies { "nl.jqno.equalsverifier:equalsverifier:$equalsverifierVersion" } -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","test") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/rlp/build.gradle b/rlp/build.gradle index 2d3255ad46..d88956f33d 100644 --- a/rlp/build.gradle +++ b/rlp/build.gradle @@ -6,5 +6,10 @@ description 'Ethereum Recursive Length Prefix (RLP) encoding for serializing obj dependencies { 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("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/tuples/build.gradle b/tuples/build.gradle index c8425a346a..f3b35c71b9 100644 --- a/tuples/build.gradle +++ b/tuples/build.gradle @@ -1,5 +1,10 @@ description 'Simple Java tuples library' -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/utils/build.gradle b/utils/build.gradle index 0b56afcce9..8e1bbf49f0 100644 --- a/utils/build.gradle +++ b/utils/build.gradle @@ -6,5 +6,10 @@ description 'Minimal set of web3j utility classes' dependencies { api "org.bouncycastle:bcprov-jdk18on:$bouncycastleVersion" } -tasks.named("spotlessJava").configure { dependsOn("spotlessGroovyGradle","compileJava","compileTestJava","javadoc","test") } -tasks.named("spotlessKotlin").configure { dependsOn("compileJava","spotlessJava", "spotlessGroovyGradle","compileTestJava","processTestResources","javadoc","test") } +tasks.named("spotlessJava").configure { + dependsOn("spotlessGroovyGradle", "compileJava", "compileTestJava", "javadoc", "test", "jacocoTestReport") +} + +tasks.named("spotlessKotlin").configure { + dependsOn("compileJava", "spotlessJava", "spotlessGroovyGradle", "compileTestJava", "processTestResources", "javadoc", "test", "jacocoTestReport") +} diff --git a/utils/src/main/java/org/web3j/utils/Bloom.java b/utils/src/main/java/org/web3j/utils/Bloom.java index a8e072b5b1..d5da1bdb64 100644 --- a/utils/src/main/java/org/web3j/utils/Bloom.java +++ b/utils/src/main/java/org/web3j/utils/Bloom.java @@ -162,12 +162,16 @@ public String toString() { return getBytesHexString(); } - /** @return Bloom filter bytes as hex string */ + /** + * @return Bloom filter bytes as hex string + */ public String getBytesHexString() { return Numeric.toHexString(this.bytes); } - /** @return Bloom filter bytes (returns a copy) */ + /** + * @return Bloom filter bytes (returns a copy) + */ public byte[] getBytes() { byte[] bytesCopy = new byte[BYTES_LENGTH]; System.arraycopy(this.bytes, 0, bytesCopy, 0, BYTES_LENGTH); diff --git a/utils/src/test/java/org/web3j/utils/BloomTest.java b/utils/src/test/java/org/web3j/utils/BloomTest.java index a514eda74f..c5709f8d48 100644 --- a/utils/src/test/java/org/web3j/utils/BloomTest.java +++ b/utils/src/test/java/org/web3j/utils/BloomTest.java @@ -20,7 +20,9 @@ import static java.util.Arrays.asList; import static org.junit.jupiter.api.Assertions.*; -/** @author Mehrdad Salehi */ +/** + * @author Mehrdad Salehi + */ public class BloomTest { // Ethereum logsBloom and logs for block