Skip to content

Commit

Permalink
Merge branch 'main' into implement-MirrorNodeContractQuery-
Browse files Browse the repository at this point in the history
  • Loading branch information
0xivanov authored Nov 25, 2024
2 parents dd5edd5 + 9b2617d commit 817e474
Show file tree
Hide file tree
Showing 26 changed files with 535 additions and 60 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
runs-on: client-sdk-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -45,7 +45,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
cache-read-only: false

Expand All @@ -59,7 +59,7 @@ jobs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -80,7 +80,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1

- name: Install Local Node
run: npm install @hashgraph/hedera-local
Expand All @@ -104,7 +104,7 @@ jobs:
- name: Upload coverage to Codecov
if: ${{ github.event_name == 'push' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') }}
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0
uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7

- name: Stop the local node
run: npx @hashgraph/hedera-local stop
Expand All @@ -116,7 +116,7 @@ jobs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -138,7 +138,7 @@ jobs:
uses: android-actions/setup-android@9fc6c4e9069bf8d3d10b2204b1fb8f6ef7065407 # v3.2.2

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1

- name: Install Local Node
run: npm install @hashgraph/hedera-local
Expand Down Expand Up @@ -171,7 +171,7 @@ jobs:
- build
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -192,7 +192,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1

- name: Install Local Node
run: npm install @hashgraph/hedera-local
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: client-sdk-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -38,7 +38,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1

- name: Compile SDK
run: ./gradlew compileJava --scan
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
runs-on: client-sdk-linux-medium
steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand All @@ -54,7 +54,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
cache-read-only: false

Expand All @@ -80,7 +80,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

Expand Down Expand Up @@ -116,7 +116,7 @@ jobs:
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@473878a77f1b98e2b5ac4af93489d1656a80a5ed # v4.2.0
uses: gradle/actions/setup-gradle@cc4fc85e6b35bafd578d5ffbc76a5518407e1af0 # v4.2.1
with:
cache-read-only: false

Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 2.45.0-beta.1

### Fixed
- Fixed a bug where optional fields for `NodeUpdateTransaction` were being set as default values.

## 2.44.0

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion docs/android-app/android-app-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To get started with an Android project, you'll need to add the following **two**

1. **Hedera™ Java SDK:**
```groovy
implementation 'com.hedera.hashgraph:sdk:2.44.0'
implementation 'com.hedera.hashgraph:sdk:2.45.0-beta.1'
```

2. **gRPC implementation:**
Expand Down
4 changes: 2 additions & 2 deletions docs/java-app/java-app-quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ To get started with a Java project, you'll need to add the following **three** d

_Gradle:_
```groovy
implementation 'com.hedera.hashgraph:sdk:2.44.0'
implementation 'com.hedera.hashgraph:sdk:2.45.0-beta.1'
```

_Maven:_
```xml
<dependency>
<groupId>com.hedera.hashgraph</groupId>
<artifactId>sdk</artifactId>
<version>2.44.0</version>
<version>2.45.0-beta.1</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion example-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ dependencies {
implementation(platform("com.hedera.hashgraph:sdk-dependency-versions"))
// ---------------------------------------------

implementation("com.hedera.hashgraph:sdk:2.44.0")
implementation("com.hedera.hashgraph:sdk:2.45.0-beta.1")

implementation("com.google.android.material:material:1.11.0")

Expand Down
4 changes: 2 additions & 2 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ mainModuleInfo {
}

dependencies.constraints {
implementation("com.hedera.hashgraph:sdk:2.44.0")
implementation("com.hedera.hashgraph:sdk-full:2.44.0")
implementation("com.hedera.hashgraph:sdk:2.45.0-beta.1")
implementation("com.hedera.hashgraph:sdk-full:2.45.0-beta.1")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2024 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package com.hedera.hashgraph.sdk.examples;

import com.hedera.hashgraph.sdk.AccountCreateTransaction;
import com.hedera.hashgraph.sdk.AccountId;
import com.hedera.hashgraph.sdk.Client;
import com.hedera.hashgraph.sdk.Hbar;
import com.hedera.hashgraph.sdk.PrivateKey;
import com.hedera.hashgraph.sdk.logger.LogLevel;
import com.hedera.hashgraph.sdk.logger.Logger;
import io.github.cdimascio.dotenv.Dotenv;
import java.util.List;
import java.util.Objects;

public class InitializeClientWithMirrorNetworkExample {
/*
* See .env.sample in the examples folder root for how to specify values below
* or set environment variables with the same names.
*/

/**
* Operator's account ID. Used to sign and pay for operations on Hedera.
*/
private static final AccountId OPERATOR_ID = AccountId.fromString(
Objects.requireNonNull(Dotenv.load().get("OPERATOR_ID")));

/**
* Operator's private key.
*/
private static final PrivateKey OPERATOR_KEY = PrivateKey.fromString(
Objects.requireNonNull(Dotenv.load().get("OPERATOR_KEY")));

/**
* SDK_LOG_LEVEL defaults to SILENT if not specified in dotenv file. Log levels can be: TRACE, DEBUG, INFO, WARN,
* ERROR, SILENT.
* <p>
* Important pre-requisite: set simple logger log level to same level as the SDK_LOG_LEVEL, for example via VM
* options: -Dorg.slf4j.simpleLogger.log.com.hedera.hashgraph=trace
*/
private static final String SDK_LOG_LEVEL = Dotenv.load().get("SDK_LOG_LEVEL", "SILENT");

public static void main(String[] args) throws Exception {
/*
* Step 0:
* Create and configure the SDK Client.
*/
Client client = Client.forMirrorNetwork(List.of("testnet.mirrornode.hedera.com:443"));
// All generated transactions will be paid by this account and signed by this key.
client.setOperator(OPERATOR_ID, OPERATOR_KEY);
// Attach logger to the SDK Client.
client.setLogger(new Logger(LogLevel.valueOf(SDK_LOG_LEVEL)));

/*
* Step 1:
* Generate ED25519 key pair.
*/
System.out.println("Generating ED25519 key pair...");
PrivateKey privateKey = PrivateKey.generateED25519();

/*
* Step 2:
* Create account
*/
AccountId aliceId = new AccountCreateTransaction()
.setKey(privateKey)
.setInitialBalance(Hbar.from(5))
.execute(client)
.getReceipt(client)
.accountId;
Objects.requireNonNull(aliceId);
System.out.println("Alice's account ID: " + aliceId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ abstract class RunAllExample : DefaultTask() {
.map { it.name.replace(".java", "") }
.filter { it != "ValidateChecksumExample" } // disabled this example, because it needs user input (but it WORKS)
.filter { it != "ConsensusPubSubChunkedExample" } // is flaky on local-node env, will be investigated
.filter { it != "InitializeClientWithMirrorNetworkExample" } // disabled - cannot run on localnode
.toList()

exampleClasses.forEach { className ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ jvmDependencyConflicts.patch {
extraJavaModuleInfo {
failOnAutomaticModules = true // Only allow Jars with 'module-info' on all module paths

module("com.esaulpaugh:headlong", "headlong")
module("com.esaulpaugh:headlong", "com.esaulpaugh.headlong")
module("com.github.spotbugs:spotbugs-annotations", "com.github.spotbugs.annotations")
module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations")
module("com.google.errorprone:error_prone_annotations", "com.google.errorprone.annotations") {
patchRealModule()
exportAllPackages()
requireAllDefinedDependencies()
}
module("com.google.guava:failureaccess", "com.google.common.util.concurrent.internal")
module("com.google.guava:guava", "com.google.common") {
exportAllPackages()
Expand Down
12 changes: 6 additions & 6 deletions sdk-dependency-versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ plugins {
}

dependencies.constraints {
api("com.esaulpaugh:headlong:12.1.0") {
api("com.esaulpaugh:headlong:12.3.3") {
because("headlong")
}
api("com.google.code.gson:gson:2.10.1") {
Expand All @@ -37,19 +37,19 @@ dependencies.constraints {
// shouldn't be updated for now (breaking changes after 4.x.x)
because("com.google.protobuf")
}
api("io.grpc:grpc-api:1.64.0") {
api("io.grpc:grpc-api:1.68.1") {
because("io.grpc")
}
api("io.grpc:grpc-inprocess:1.64.0") {
api("io.grpc:grpc-inprocess:1.67.1") {
because("io.grpc.protobuf")
}
api("io.grpc:grpc-protobuf:1.64.0") {
api("io.grpc:grpc-protobuf:1.68.1") {
because("io.grpc.protobuf")
}
api("io.grpc:grpc-protobuf-lite:1.64.0") {
api("io.grpc:grpc-protobuf-lite:1.68.1") {
because("io.grpc.protobuf")
}
api("io.grpc:grpc-stub:1.64.0") {
api("io.grpc:grpc-stub:1.68.1") {
because("io.grpc.stub")
}
api("com.google.code.findbugs:jsr305:3.0.2") {
Expand Down
2 changes: 1 addition & 1 deletion sdk-full/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
module com.hedera.hashgraph.sdk.full {
requires transitive com.google.protobuf;

requires com.esaulpaugh.headlong;
requires com.google.common;
requires com.google.gson;
requires headlong;
requires io.grpc.inprocess;
requires io.grpc.protobuf;
requires io.grpc.stub;
Expand Down
23 changes: 20 additions & 3 deletions sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,24 @@ public static Client forNetwork(Map<String, AccountId> networkMap) {
return new Client(executor, network, mirrorNetwork, null, true, null);
}

/**
* Set up the client from selected mirror network.
*
* @param mirrorNetworkList
* @return
*/
public static Client forMirrorNetwork(List<String> mirrorNetworkList) throws InterruptedException, TimeoutException {
var executor = createExecutor();
var network = Network.forNetwork(executor, new HashMap<>());
var mirrorNetwork = MirrorNetwork.forNetwork(executor, mirrorNetworkList);
var client = new Client(executor, network, mirrorNetwork, null, true, null);
var addressBook = new AddressBookQuery()
.setFileId(FileId.ADDRESS_BOOK)
.execute(client);
client.setNetworkFromAddressBook(addressBook);
return client;
}

/**
* Set up the client for the selected network.
*
Expand Down Expand Up @@ -1418,8 +1436,8 @@ private Client toClient() throws Exception, InterruptedException {
private Client initializeWithNetwork() throws Exception {
if (network == null) {
throw new Exception("Network is not set in provided json object");
}
}

Client client;
if (network.isJsonObject()) {
client = clientFromNetworkJson();
Expand Down Expand Up @@ -1501,7 +1519,6 @@ private void setOperatorOn(Client client) {
if (operator != null) {
AccountId operatorAccount = AccountId.fromString(operator.accountId);
PrivateKey privateKey = PrivateKey.fromString(operator.privateKey);

client.setOperator(operatorAccount, privateKey);
}
}
Expand Down
Loading

0 comments on commit 817e474

Please sign in to comment.