Skip to content

Commit f2a5d9c

Browse files
authored
Merge pull request #121 from LFDT-web3j/bump-4.14.1-snap
Bump 4.14.1 snap
2 parents 44d340d + 034d398 commit f2a5d9c

File tree

53 files changed

+802
-619
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+802
-619
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Build Workflow Dispatch
1818
uses: convictional/[email protected]
1919
with:
20-
owner: hyperledger-web3j
20+
owner: LFDT-web3j
2121
repo: web3j-openapi
2222
github_token: ${{ secrets.GITHUB_TOKEN }}
2323
workflow_file_name: build.yml

CHANGELOG.md

+15-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,21 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6-
# [4.14.0]() (Upcoming)
6+
# [4.14.1]() (Upcoming)
7+
8+
### Bug Fixes
9+
10+
*
11+
12+
### Features
13+
14+
* Bump SNAPSHOT version to 4.14.1 [#121](https://github.com/hyperledger/web3j-openapi/pull/121)
15+
16+
### BREAKING CHANGES
17+
18+
*
19+
20+
# [4.14.0](https://github.com/LFDT-web3j/web3j-openapi/releases/tag/v4.14.0) (2025-04-11)
721

822
### Bug Fixes
923

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ The easiest way to interact with the generated project is via the generated `Swa
6565
Also, you can use our client implementation via adding the following dependency to your project:
6666
```groovy
6767
dependencies {
68-
implementation "org.web3j.openapi:web3j-openapi-client:4.13.0"
68+
implementation "org.web3j.openapi:web3j-openapi-client:4.14.0"
6969
}
7070
```
7171

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010

1111
plugins {
1212
id 'de.undercouch.download' version '4.1.2'
13-
id 'com.diffplug.spotless' version '6.25.0'
13+
id 'com.diffplug.spotless' version '7.0.3'
1414
id 'io.codearte.nexus-staging' version '0.30.0'
1515
id 'de.marcphilipp.nexus-publish' version '0.4.0'
1616
}

client/src/main/kotlin/org/web3j/openapi/client/ClientService.kt

+34-34
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,43 @@ import java.util.logging.Level
2929
import java.util.logging.Logger
3030

3131
class ClientService
32-
@JvmOverloads
33-
constructor(
34-
val uri: String,
35-
readTimeout: Int = DEFAULT_READ_TIMEOUT,
36-
connectTimeout: Int = DEFAULT_CONNECT_TIMEOUT,
37-
) : AutoCloseable {
38-
private val mapper =
39-
jacksonObjectMapper()
40-
.setDefaultSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY))
41-
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
42-
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
43-
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
44-
.enable(SerializationFeature.INDENT_OUTPUT)
32+
@JvmOverloads
33+
constructor(
34+
val uri: String,
35+
readTimeout: Int = DEFAULT_READ_TIMEOUT,
36+
connectTimeout: Int = DEFAULT_CONNECT_TIMEOUT,
37+
) : AutoCloseable {
38+
private val mapper =
39+
jacksonObjectMapper()
40+
.setDefaultSetterInfo(JsonSetter.Value.forContentNulls(Nulls.AS_EMPTY))
41+
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
42+
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
43+
.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)
44+
.enable(SerializationFeature.INDENT_OUTPUT)
4545

46-
internal val client: Client by lazy {
47-
val config =
48-
ClientConfig().apply {
49-
// Redirect ALL logs to SLF4J using logging.properties
50-
register(LoggingFeature(logger.apply { level = Level.ALL }, Short.MAX_VALUE.toInt()))
51-
register(JacksonJaxbJsonProvider(mapper, arrayOf(Annotations.JACKSON)))
52-
property(ClientProperties.READ_TIMEOUT, readTimeout)
53-
property(ClientProperties.CONNECT_TIMEOUT, connectTimeout)
54-
}
55-
ClientBuilder.newClient(config)
56-
}
46+
internal val client: Client by lazy {
47+
val config =
48+
ClientConfig().apply {
49+
// Redirect ALL logs to SLF4J using logging.properties
50+
register(LoggingFeature(logger.apply { level = Level.ALL }, Short.MAX_VALUE.toInt()))
51+
register(JacksonJaxbJsonProvider(mapper, arrayOf(Annotations.JACKSON)))
52+
property(ClientProperties.READ_TIMEOUT, readTimeout)
53+
property(ClientProperties.CONNECT_TIMEOUT, connectTimeout)
54+
}
55+
ClientBuilder.newClient(config)
56+
}
5757

58-
override fun close() = client.close()
58+
override fun close() = client.close()
5959

60-
companion object {
61-
const val DEFAULT_READ_TIMEOUT: Int = 60000
62-
const val DEFAULT_CONNECT_TIMEOUT: Int = 60000
60+
companion object {
61+
const val DEFAULT_READ_TIMEOUT: Int = 60000
62+
const val DEFAULT_CONNECT_TIMEOUT: Int = 60000
6363

64-
init {
65-
SLF4JBridgeHandler.removeHandlersForRootLogger()
66-
SLF4JBridgeHandler.install()
67-
}
64+
init {
65+
SLF4JBridgeHandler.removeHandlersForRootLogger()
66+
SLF4JBridgeHandler.install()
67+
}
6868

69-
private val logger = Logger.getLogger(ClientService::class.java.canonicalName)!!
69+
private val logger = Logger.getLogger(ClientService::class.java.canonicalName)!!
70+
}
7071
}
71-
}

codegen/src/integration-test/kotlin/org/web3j/openapi/codegen/generators/GenerationTest.kt

+16-14
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,28 @@ import java.io.File
2222
import java.nio.file.Paths
2323

2424
class GenerationTest {
25-
2625
@TempDir
2726
lateinit var tempFolder: File
2827

2928
@Test
3029
fun `generate project Gradle tasks`() {
31-
val contractsFolder = Paths.get(
32-
"src",
33-
"test",
34-
"resources",
35-
"contracts",
36-
).toFile()
30+
val contractsFolder =
31+
Paths
32+
.get(
33+
"src",
34+
"test",
35+
"resources",
36+
"contracts",
37+
).toFile()
3738

38-
val generatorConfiguration = GeneratorConfiguration(
39-
projectName = "testProject",
40-
packageName = "com.test",
41-
outputDir = tempFolder.canonicalPath,
42-
contracts = loadContractConfigurations(listOf(contractsFolder)),
43-
contextPath = "test",
44-
)
39+
val generatorConfiguration =
40+
GeneratorConfiguration(
41+
projectName = "testProject",
42+
packageName = "com.test",
43+
outputDir = tempFolder.canonicalPath,
44+
contracts = loadContractConfigurations(listOf(contractsFolder)),
45+
contextPath = "test",
46+
)
4547
assertDoesNotThrow {
4648
OpenApiGenerator(generatorConfiguration).generate()
4749
}

codegen/src/main/kotlin/org/web3j/openapi/codegen/common/Import.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
*/
1313
package org.web3j.openapi.codegen.common
1414

15-
data class Import(val import: String)
15+
data class Import(
16+
val import: String,
17+
)

codegen/src/main/kotlin/org/web3j/openapi/codegen/config/ContractDetails.kt

+12-9
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ data class ContractDetails(
2121
var abiDefinitions: List<AbiDefinition>,
2222
) {
2323
init {
24-
abiDefinitions.filter { it.isPayable }
24+
abiDefinitions
25+
.filter { it.isPayable }
2526
.forEach { it.inputs.add(AbiDefinition.NamedType("weiValue", "uint")) }
26-
abiDefinitions = handleDuplicateNames(handleDuplicateNames(abiDefinitions, "event"), "function")
27-
.apply { forEach { abiDefinition -> abiDefinition.inputs = handleDuplicateInputNames(abiDefinition.inputs) } }
27+
abiDefinitions =
28+
handleDuplicateNames(handleDuplicateNames(abiDefinitions, "event"), "function")
29+
.apply { forEach { abiDefinition -> abiDefinition.inputs = handleDuplicateInputNames(abiDefinition.inputs) } }
2830
}
2931

3032
val lowerCaseContractName: String
@@ -37,10 +39,11 @@ data class ContractDetails(
3739
get() = contractName.decapitalize()
3840

3941
val deployParameters: String
40-
get() = abiDefinitions
41-
.filter { it.type == "constructor" }
42-
.firstOrNull { it.inputs.isNotEmpty() }
43-
?.run {
44-
"(parameters: ${capitalizedContractName}DeployParameters)"
45-
} ?: "()"
42+
get() =
43+
abiDefinitions
44+
.filter { it.type == "constructor" }
45+
.firstOrNull { it.inputs.isNotEmpty() }
46+
?.run {
47+
"(parameters: ${capitalizedContractName}DeployParameters)"
48+
} ?: "()"
4649
}

codegen/src/main/kotlin/org/web3j/openapi/codegen/config/GeneratorConfiguration.kt

+17-15
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,22 @@ package org.web3j.openapi.codegen.config
1515
import org.jetbrains.kotlin.ir.backend.js.utils.sanitizeName
1616
import org.web3j.abi.datatypes.Address
1717

18-
data class GeneratorConfiguration @JvmOverloads constructor(
19-
val projectName: String,
20-
var packageName: String,
21-
val outputDir: String,
22-
val contracts: List<ContractConfiguration>,
23-
val addressLength: Int = Address.DEFAULT_LENGTH / java.lang.Byte.SIZE,
24-
val contextPath: String,
25-
val version: String = VersionProvider.versionName,
26-
val sanitizedProjectName: String = sanitizeName(projectName),
27-
val withImplementations: Boolean = true,
28-
) {
29-
val rootProjectName = sanitizedProjectName.lowercase().replace(' ', '-')
18+
data class GeneratorConfiguration
19+
@JvmOverloads
20+
constructor(
21+
val projectName: String,
22+
var packageName: String,
23+
val outputDir: String,
24+
val contracts: List<ContractConfiguration>,
25+
val addressLength: Int = Address.DEFAULT_LENGTH / java.lang.Byte.SIZE,
26+
val contextPath: String,
27+
val version: String = VersionProvider.versionName,
28+
val sanitizedProjectName: String = sanitizeName(projectName),
29+
val withImplementations: Boolean = true,
30+
) {
31+
val rootProjectName = sanitizedProjectName.lowercase().replace(' ', '-')
3032

31-
init {
32-
packageName = packageName.lowercase()
33+
init {
34+
packageName = packageName.lowercase()
35+
}
3336
}
34-
}

codegen/src/main/kotlin/org/web3j/openapi/codegen/config/VersionProvider.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,28 +19,28 @@ import java.time.format.DateTimeFormatter
1919
import java.util.Properties
2020

2121
object VersionProvider {
22-
2322
val versionName: String
2423
val buildTimestamp: OffsetDateTime
2524

2625
private val timeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS O")
2726

2827
init {
29-
val url = javaClass.classLoader.getResource("openapi-version.properties")
30-
?: throw IllegalStateException("No openapi-version.properties file found in the classpath.")
28+
val url =
29+
javaClass.classLoader.getResource("openapi-version.properties")
30+
?: throw IllegalStateException("No openapi-version.properties file found in the classpath.")
3131

3232
val properties = Properties().apply { load(url.openStream()) }
3333

3434
versionName = properties.getProperty("version")
35-
buildTimestamp = properties.getProperty("timestamp").toLong().let {
36-
Instant.ofEpochMilli(it).atOffset(ZoneOffset.UTC)
37-
}
35+
buildTimestamp =
36+
properties.getProperty("timestamp").toLong().let {
37+
Instant.ofEpochMilli(it).atOffset(ZoneOffset.UTC)
38+
}
3839
}
3940

40-
fun getVersion(): Array<String> {
41-
return arrayOf(
41+
fun getVersion(): Array<String> =
42+
arrayOf(
4243
"Version: $versionName",
4344
"Build timestamp: ${buildTimestamp.let { timeFormatter.format(it) }}",
4445
)
45-
}
4646
}

codegen/src/main/kotlin/org/web3j/openapi/codegen/coregen/CoreGenerator.kt

+13-10
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import java.nio.file.Paths
2828
class CoreGenerator(
2929
configuration: GeneratorConfiguration,
3030
) : AbstractGenerator(
31-
configuration,
32-
) {
31+
configuration,
32+
) {
3333
init {
3434
context["contractsConfiguration"] = configuration.contracts
3535
context["apiImports"] = getApiImports()
@@ -48,10 +48,12 @@ class CoreGenerator(
4848
logger.debug("Generating ${it.contractDetails.capitalizedContractName} Open API folders and files")
4949
CoreApiGenerator(
5050
configuration.packageName,
51-
folderPath = Paths.get(
52-
folderPath,
53-
it.contractDetails.lowerCaseContractName,
54-
).toString(),
51+
folderPath =
52+
Paths
53+
.get(
54+
folderPath,
55+
it.contractDetails.lowerCaseContractName,
56+
).toString(),
5557
contractDetails = it.contractDetails,
5658
).generate()
5759
}
@@ -78,11 +80,12 @@ class CoreGenerator(
7880
}
7981
}
8082

81-
private fun getApiImports(): List<Import> {
82-
return configuration.contracts.map {
83-
Import("import ${configuration.packageName}.core.${it.contractDetails.lowerCaseContractName}.${it.contractDetails.capitalizedContractName}")
83+
private fun getApiImports(): List<Import> =
84+
configuration.contracts.map {
85+
Import(
86+
"import ${configuration.packageName}.core.${it.contractDetails.lowerCaseContractName}.${it.contractDetails.capitalizedContractName}",
87+
)
8488
}
85-
}
8689

8790
private fun copySources(folderPath: String) {
8891
generateFromTemplate(

codegen/src/main/kotlin/org/web3j/openapi/codegen/coregen/subgenerators/CoreApiGenerator.kt

+16-14
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ internal class CoreApiGenerator(
6666
}
6767
}
6868

69-
private fun modelImports(): List<Import> {
70-
return contractDetails.abiDefinitions
69+
private fun modelImports(): List<Import> =
70+
contractDetails.abiDefinitions
7171
.filter { it.type == "function" && it.inputs.isNotEmpty() || it.type == "event" }
7272
.map {
7373
if (it.type == "function") {
@@ -84,10 +84,9 @@ internal class CoreApiGenerator(
8484
)
8585
}
8686
}
87-
}
8887

89-
private fun eventImports(): List<Import> {
90-
return contractDetails.abiDefinitions
88+
private fun eventImports(): List<Import> =
89+
contractDetails.abiDefinitions
9190
.filter { it.type == "event" }
9291
.map {
9392
Import(
@@ -96,7 +95,6 @@ internal class CoreApiGenerator(
9695
}EventResource",
9796
)
9897
}
99-
}
10098

10199
private fun contractResources(): ContractResources {
102100
val functionResources = mutableListOf<FunctionResource>()
@@ -123,8 +121,10 @@ internal class CoreApiGenerator(
123121
functionName = sanitizedAbiDefinitionName,
124122
resource = "fun $sanitizedAbiDefinitionName($parameters)",
125123
method = if (it.inputs.isEmpty()) "@GET" else "@POST",
126-
returnType = it.getReturnType(packageName, contractDetails.lowerCaseContractName)
127-
.toString(),
124+
returnType =
125+
it
126+
.getReturnType(packageName, contractDetails.lowerCaseContractName)
127+
.toString(),
128128
operationTag = operationTag,
129129
mediaType = "@Produces(MediaType.APPLICATION_JSON)",
130130
path = "@Path(\"$sanitizedAbiDefinitionName\")",
@@ -203,12 +203,14 @@ internal class CoreApiGenerator(
203203
name = "${contractDetails.capitalizedContractName}Events.kt",
204204
)
205205

206-
val eventsFolder = File(
207-
Paths.get(
208-
folderPath,
209-
"events",
210-
).toString(),
211-
)
206+
val eventsFolder =
207+
File(
208+
Paths
209+
.get(
210+
folderPath,
211+
"events",
212+
).toString(),
213+
)
212214

213215
contractDetails.abiDefinitions
214216
.filter { it.type == "event" }

0 commit comments

Comments
 (0)