Skip to content

[1.1.1] #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 25 additions & 22 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ on:
push:
branches:
- master
schedule:
- cron: "0 12 1 * *"
pull_request:
branches:
- master
- dev
- master
- dev

jobs:
build:
Expand All @@ -20,21 +18,26 @@ jobs:
name: Java ${{ matrix.java }} setup

steps:
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1

with:
java-version: ${{ matrix.java }}

- name: Build with Gradle
run: ./gradlew build jacocoTestReport
env:
API_KEY: ${{ secrets.API_KEY }}

- name: Analyze with SonarQube
run: ./gradlew sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
API_KEY: ${{ secrets.API_KEY }}
- uses: actions/checkout@v1
- name: Set up JDK
uses: actions/setup-java@v1

with:
java-version: ${{ matrix.java }}

- name: Build
run: ./gradlew classes

- name: Codestyle
run: ./gradlew spotlessCheck

- name: Test
run: ./gradlew test jacocoTestReport
env:
API_KEY: ${{ secrets.API_KEY }}

- name: SonarQube
run: ./gradlew sonarqube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43 changes: 25 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
Library supports all available EtherScan *API* calls for all available *Ethereum Networks* for *etherscan.io*

## Dependency :rocket:

**Gradle**
```groovy
dependencies {
compile "com.github.goodforgod:java-etherscan-api:1.1.1"
}
```

**Maven**
```xml
<dependency>
<groupId>com.github.goodforgod</groupId>
<artifactId>java-etherscan-api</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>
```

**Gradle**
```groovy
dependencies {
compile 'com.github.goodforgod:java-etherscan-api:1.1.0'
}
```

## Content
- [Ethereum Networks](#mainnet-and-testnets)
- [Custom HttpClient](#custom-httpclient)
Expand All @@ -42,6 +43,7 @@ dependencies {
- [Version History](#version-history)

## Mainnet and Testnets

API support Ethereum: *[MAINNET](https://etherscan.io),
[ROPSTEN](https://ropsten.etherscan.io),
[KOVAN](https://kovan.etherscan.io),
Expand Down Expand Up @@ -88,14 +90,18 @@ EtherScanApi api = new EtherScanApi("YourApiKey");
Below are examples for each API category.

### Account Api

**Get Ether Balance for a single Address**

```java
EtherScanApi api = new EtherScanApi();
Balance balance = api.account().balance("0x8d4426f94e42f721C7116E81d6688cd935cB3b4F");
```

### Block Api

**Get uncles block for block height**

```java
EtherScanApi api = new EtherScanApi();
Optional<UncleBlock> uncles = api.block().uncles(200000);
Expand All @@ -109,7 +115,9 @@ Abi abi = api.contract().contractAbi("0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413
```

### Logs Api

**Get event logs for single topic**

```java
EtherScanApi api = new EtherScanApi();
LogQuery query = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c")
Expand All @@ -119,6 +127,7 @@ List<Log> logs = api.logs().logs(query);
```

**Get event logs for 3 topics with respectful operations**

```java
EtherScanApi api = new EtherScanApi();
LogQuery query = LogQueryBuilder.with("0x33990122638b9132ca29c723bdf037f1a891a70c", 379224, 400000)
Expand All @@ -134,47 +143,45 @@ List<Log> logs = api.logs().logs(query);
```

### Proxy Api

**Get tx detailds with proxy endpoint**

```java
EtherScanApi api = new EtherScanApi(EthNetwork.MAINNET);
Optional<TxProxy> tx = api.proxy().tx("0x1e2910a262b1008d0616a0beb24c1a491d78771baa54a33e66065e03b1f46bc1");
```

**Get block info with proxy endpoint**

```java
EtherScanApi api = new EtherScanApi(EthNetwork.MAINNET);
Optional<BlockProxy> block = api.proxy().block(15215);
```

### Stats Api

**Statistic about last price**

```java
EtherScanApi api = new EtherScanApi();
Price price = api.stats().lastPrice();
```

### Transaction Api

**Request receipt status for tx**

```java
EtherScanApi api = new EtherScanApi();
Optional<Boolean> status = api.txs().receiptStatus("0x513c1ba0bebf66436b5fed86ab668452b7805593c05073eb2d51d3a52f480a76");
```

### Token Api

You can read about token API [here](https://etherscan.io/apis#tokens)

Token API methods migrated to [Account](#account-api) & [Stats](#stats-api) respectfully.

## Version History

**1.1.0** - Improved error handling, QueueManager improved, Gradle 6.7 instead of Maven, GitHub CI, Sonarcloud analyzer, dependencies updated.

**1.0.2** - Minor http client improvements.

**1.0.1** - Gorli & TOBALABA networks support.

**1.0.0** - Initial project with all API functionality, for all available networks, with tests coverage for all cases.

## License

This project licensed under the MIT - see the [LICENSE](LICENSE) file for details.
109 changes: 53 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,71 +1,57 @@
plugins {
id 'jacoco'
id 'java-library'
id 'maven-publish'
id "jacoco"
id "java-library"
id "maven-publish"

id 'org.sonarqube' version '3.1.1'
id 'com.diffplug.spotless' version '5.11.0'
id "org.sonarqube" version "3.3"
id "com.diffplug.spotless" version "5.14.3"
}

repositories {
mavenLocal()
mavenCentral()
jcenter()
}

group = groupId
version = artifactVersion

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

spotless {
java {
encoding 'UTF-8'
encoding "UTF-8"
removeUnusedImports()
eclipse().configFile "${projectDir}/config/codestyle.xml"
}
}

sonarqube {
properties {
property 'sonar.host.url', 'https://sonarcloud.io'
property 'sonar.organization', 'goodforgod'
property 'sonar.projectKey', 'GoodforGod_java-etherscan-api'
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.organization", "goodforgod"
property "sonar.projectKey", "GoodforGod_java-etherscan-api"
}
}

dependencies {
implementation 'org.jetbrains:annotations:20.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "org.jetbrains:annotations:22.0.0"
implementation "com.google.code.gson:gson:2.8.8"

testImplementation 'junit:junit:4.13.1'
testImplementation "junit:junit:4.13.1"
}

test {
failFast = true

useJUnit()
testLogging {
events "passed", "skipped", "failed"
exceptionFormat "full"
events("passed", "skipped", "failed")
exceptionFormat("full")
}
}

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.incremental = true
options.fork = true
}

tasks.withType(Test) {
reports.html.enabled = false
reports.junitXml.enabled = false
}

java {
withJavadocJar()
withSourcesJar()
reports {
html.enabled(false)
junitXml.enabled(false)
}
}

publishing {
Expand All @@ -74,27 +60,27 @@ publishing {
from components.java

pom {
name = 'Java Etherscan API'
url = 'https://github.com/GoodforGod/java-etherscan-api'
description = 'Library is a wrapper for EtherScan API.'
name = "Java Etherscan API"
url = "https://github.com/GoodforGod/java-etherscan-api"
description = "Library is a wrapper for EtherScan API."

license {
name = 'MIT License'
url = 'https://github.com/GoodforGod/java-etherscan-api/blob/master/LICENSE'
distribution = 'repo'
name = "MIT License"
url = "https://github.com/GoodforGod/java-etherscan-api/blob/master/LICENSE"
distribution = "repo"
}

developer {
id = 'GoodforGod'
name = 'Anton Kurako'
email = 'goodforgod.dev@gmail.com'
url = 'https://github.com/GoodforGod'
id = "GoodforGod"
name = "Anton Kurako"
email = "goodforgod.dev@gmail.com"
url = "https://github.com/GoodforGod"
}

scm {
connection = 'scm:git:git://github.com/GoodforGod/java-etherscan-api.git'
developerConnection = 'scm:git:ssh://GoodforGod/java-etherscan-api.git'
url = 'https://github.com/GoodforGod/java-etherscan-api/tree/master'
connection = "scm:git:git://github.com/GoodforGod/java-etherscan-api.git"
developerConnection = "scm:git:ssh://GoodforGod/java-etherscan-api.git"
url = "https://github.com/GoodforGod/java-etherscan-api/tree/master"
}
}
}
Expand All @@ -103,7 +89,7 @@ publishing {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
url = version.endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username System.getenv("OSS_USERNAME")
password System.getenv("OSS_PASSWORD")
Expand All @@ -112,6 +98,17 @@ publishing {
}
}

java {
withJavadocJar()
withSourcesJar()
}

tasks.withType(JavaCompile) {
options.encoding("UTF-8")
options.incremental(true)
options.fork = true
}

check.dependsOn jacocoTestReport
jacocoTestReport {
reports {
Expand All @@ -120,16 +117,16 @@ jacocoTestReport {
}
}

javadoc {
options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}

if (project.hasProperty("signing.keyId")) {
apply plugin: 'signing'
apply plugin: "signing"
signing {
sign publishing.publications.mavenJava
}
}

javadoc {
options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
2 changes: 1 addition & 1 deletion config/codestyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="100"/>
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_if_empty"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
groupId=com.github.goodforgod
artifactId=java-etherscan-api
artifactVersion=1.1.0
artifactVersion=1.1.1
buildNumber=1


Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Loading