Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
Signed-off-by: Nischal Sharma <[email protected]>
  • Loading branch information
NickSneo committed Oct 4, 2024
1 parent f8994ad commit 8f3c0b2
Show file tree
Hide file tree
Showing 18 changed files with 237 additions and 162 deletions.
25 changes: 10 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Web3j Open API
[![Build Status](https://travis-ci.org/web3j/web3j-openapi.svg?branch=master)](https://travis-ci.org/web3j/web3j-openapi)

Web3j-OpenAPI is a [OpenAPI](https://swagger.io/specification/) client and server generator from
[Solidity](https://solidity.readthedocs.io/) smart contracts. it provides a way to interact with the Ethereum blockchain via simple and intuitive HTTP requests, abstracting the coding layer. These interactions can be done using :
[Solidity](https://solidity.readthedocs.io/) smart contracts. it provides a way to interact with the Ethereum blockchain via simple and intuitive
HTTP requests, abstracting the coding layer. These interactions can be done using :
- Plain HTTP requests
- Via the `Swagger-UI`, which is generated with every project
- A client application using the [`webj3-openapi-client`](/client) implementation
Expand All @@ -16,31 +17,25 @@ The workflow can be summed in the following steps:
- Sending HTTP requests using `Swagger-UI`, client application or `Curl` request.

# Getting started with Web3j-OpenAPI
To generate an OpenAPI project using the [Web3j-OpenAPI](https://github.com/web3j/web3j-openapi) generator, you need to have the [Epirus-CLI](https://docs.epirus.io/quickstart) installed on your machine (Note - the Epirus CLI has replaced the Web3j CLI).
It’s easy to do (for Windows instructions head [here](https://docs.epirus.io/quickstart/#installation)):
To generate an OpenAPI project using the [Web3j-OpenAPI](https://github.com/hyperledger/web3j-openapi) generator,
you need to have the [Web3j-CLI](https://docs.web3j.io/latest/command_line_tools/) installed on your machine.
It’s easy to do (for Windows instructions head [here](https://github.com/hyperledger/web3j-cli/)):

```ssh
$ curl -L get.epirus.io | sh
$ curl -L get.web3j.io | sh
```

### Create a Hello World project
To create a base OpenAPI project using a `Hello World` contract, run the following :

```ssh
$ epirus openapi new
$ web3j openapi new
```

You can also generate a `Web3j-OpenAPI` project using the [Web3j-OpenAPI-gradle-plugin](https://github.com/web3j/web3j-openapi-gradle-plugin).

### Configure the project
After having the generated project, you can use the [Epirus-CLI](https://docs.epirus.io) to run it using the following command (Note: You will need to create an [Epirus](https://www.web3labs.com/epirus) Account).

```ssh
$ epirus login
$ epirus run rinkeby|ropsten
```

Alternatively, you can configure your application with the following environment variables:
After having the generated project, you can configure your application with the following environment variables:

```ssh
$ export WEB3J_ENDPOINT=<link_to_your_Ethereum_node>
Expand All @@ -50,7 +45,7 @@ $ export WEB3J_OPENAPI_PORT=9090
```

### Run the project
If you aren't using the [Epirus-CLI](https://docs.epirus.io/quickstart/#deployment), you may run the project using the following Gradle target:
If you aren't using the Web3j-CLI you may run the project using the following Gradle target:

```ssh
$ cd <project_folder>
Expand All @@ -70,7 +65,7 @@ The easiest way to interact with the generated project is via the generated `Swa
Also, you can use our client implementation via adding the following dependency to your project:
```groovy
dependencies {
implementation "org.web3j.openapi:web3j-openapi-client:4.7.1"
implementation "org.web3j.openapi:web3j-openapi-client:4.12.2"
}
```

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}"
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:4.0.0'
classpath 'org.unbroken-dome.gradle-plugins:gradle-testsets-plugin:4.1.0'
}
}

Expand Down
1 change: 1 addition & 0 deletions client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dependencies {

tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("compileKotlin"))
}

tasks.named("spotlessKotlin") {
Expand Down
12 changes: 9 additions & 3 deletions codegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,17 @@ task copyIntegrationTestResources(type: Copy) {

integrationTest.dependsOn copyIntegrationTestResources, publishToMavenLocal

tasks.named("spotlessJava") {
tasks.named("spotlessKotlin") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("spotlessJava"))
dependsOn(tasks.named("test"))
}

tasks.named("spotlessKotlin") {
tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("spotlessJava"))
dependsOn(tasks.named("compileKotlin"))
dependsOn(tasks.named("compileTestKotlin"))
dependsOn(tasks.named("processResources"))
dependsOn(tasks.named("processTestResources"))
dependsOn(tasks.named("test"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ internal val String.structName
fun extractStructs(
functionDefinitions: List<AbiDefinition>,
): List<AbiDefinition.NamedType?>? {
val structMap: HashMap<Int, AbiDefinition.NamedType> =
LinkedHashMap()
val structMap: HashMap<String, AbiDefinition.NamedType> = LinkedHashMap()
functionDefinitions.stream()
.flatMap { definition: AbiDefinition ->
val parameters: MutableList<AbiDefinition.NamedType> =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class KPoetUtilsTest {
val expectedOutput = """
package test
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.`annotation`.JsonProperty
import java.math.BigInteger
import kotlin.String
data class TestFunctionParameters(
public data class TestFunctionParameters(
@JsonProperty(value = "number")
val number: BigInteger,
public val number: BigInteger,
@JsonProperty(value = "string")
val string: String
public val string: String,
)
""".replace("\\s".toRegex(), "")

Expand Down
1 change: 1 addition & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ dependencies {

tasks.named("spotlessJava") {
dependsOn(tasks.named("spotlessGroovyGradle"))
dependsOn(tasks.named("compileKotlin"))
}

tasks.named("spotlessKotlin") {
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ version=4.12.2-SNAPSHOT
kotlin.code.style=official
kotlin.caching.enabled=true
kotlin.incremental=true
kotlinVersion=1.8.10
kotlinVersion=1.9.24
org.gradle.caching=true
org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2g
6 changes: 3 additions & 3 deletions gradle/publish/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ apply plugin: 'signing'
apply plugin: "de.marcphilipp.nexus-publish"

task javadocsJar(type: Jar) {
archiveClassifier = 'javadoc'
archiveClassifier.set('javadoc')
from javadoc
}

task sourcesJar(type: Jar) {
archiveClassifier = 'sources'
archiveClassifier.set('sources')
from sourceSets.main.allSource
}

task testsJar(type: Jar) {
archiveClassifier = 'tests'
archiveClassifier.set('tests')
from sourceSets.test.output
}

Expand Down
3 changes: 3 additions & 0 deletions gradle/repositories/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
repositories {
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
jcenter()
maven { url 'https://oss.sonatype.org/content/repositories/releases/' }
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 2 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 8f3c0b2

Please sign in to comment.