Skip to content

Commit

Permalink
Merge branch 'develop' into add-contract-function-parameters-integrat…
Browse files Browse the repository at this point in the history
…ion-tests
  • Loading branch information
thenswan committed Jul 31, 2023
2 parents 804327a + 23d6fbb commit 45c4e17
Show file tree
Hide file tree
Showing 54 changed files with 1,375 additions and 392 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Default code owners for entire repository
* @dikel @SimiHunjan
* @thenswan @SimiHunjan
27 changes: 2 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,31 +42,8 @@ jobs:
run: ./gradlew compileIntegrationTestJava
- name: Compile Examples
run: ./gradlew :examples:compileJava

build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build
run: ./gradlew build

- name: Generate Javadoc
run: ./gradlew sdk:javadoc
test:
runs-on: ubuntu-latest

Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.26.0

### Added
- `contractNonces` to `ContractFunctionResult`
- Support for ECDSA keys generated by OpenSSL

## 2.25.0

### Added
Expand All @@ -24,6 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed
- The `transactionId` nanoseconds are now left padded with 0s for 9 chars
- Importing and exporting ECDSA keys to DER format is now compatible with OpenSSL

## 2.24.0

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Select _one_ of the following depending on your target platform.

```groovy
implementation 'com.hedera.hashgraph:sdk:2.25.0'
implementation 'com.hedera.hashgraph:sdk:2.26.0'
```

Select _one_ of the following to provide the gRPC implementation.
Expand Down Expand Up @@ -56,7 +56,7 @@ Select _one_ of the following depending on your target platform.
<dependency>
<groupId>com.hedera.hashgraph</groupId>
<artifactId>sdk</artifactId>
<version>2.25.0</version>
<version>2.26.0</version>
</dependency>
```

Expand Down
33 changes: 33 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Release process of Java SDK

### Setup

- Create an account in [sonatype](https://issues.sonatype.org/secure/Signup!default.jspa)
- Someone has to create a JIRA ticket to add your account to the "com.hedera" group ([example](https://issues.sonatype.org/browse/OSSRH-85535))
- Add these properties in your global `gradle.properties` file (`~/.gradle/gradle.properties`):
- `sonatypeUsername=<your-email>`
- `sonatypePassword=<your-password>`
- `signing.keyId=<last-8-characters-of-your-GPG-key`
- `signing.password=<password-of-the-key>`
- `signing.secretKeyRingFile=/Users/<user>/.gnupg/secring.gpg`

### Releasing

- Make sure you don’t have any uncommitted changes (The publish task will remove them)
- **Run** the [local node](https://github.com/hashgraph/hedera-local-node)
- Run `task test:integration`
- **Stop** the local node
- Run `task test:unit`
- Create a new branch: `release/vX.Y.Z`
- Change the version in `version.gradle`
- Change the version in `CHANGELOG.md` (from unreleased)
- Change the version in `example-android/app/build.gradle`
- Change the version in README.md (Once in the Gradle section and once in the Maven section)
- Push the changes
- run `task publish`
- Create a PR to merge release/vX.Y.Z to develop
- Finally, merge develop to main
- Go to the [SDK PAGE](https://github.com/hashgraph/hedera-sdk-js/releases) and press the “Draft a new release” button
- Create a new tag from the branch that you are releasing (release/vX.Y.Z) with the same version of the branch
- Copy the latest changes from CHANGELOG.md to the description of the release
- Publish Release
18 changes: 11 additions & 7 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ tasks:

"test:integration":
cmds:
- ./gradlew -POPERATOR_KEY=$OPERATOR_KEY -POPERATOR_ID=$OPERATOR_ID -PCONFIG_FILE=$CONFIG_FILE integrationTest {{.CLI_ARGS}}
- ./gradlew -POPERATOR_ID=$OPERATOR_ID -POPERATOR_KEY=$OPERATOR_KEY -PHEDERA_NETWORK=$HEDERA_NETWORK integrationTest {{.CLI_ARGS}}
env:
OPERATOR_KEY: '0xa608e2130a0a3cb34f86e757303c862bee353d9ab77ba4387ec084f881d420d4'
OPERATOR_ID: '0.0.1022'
HEDERA_NETWORK: 'localhost'

"update:snapshots":
cmds:
Expand Down Expand Up @@ -66,15 +70,15 @@ tasks:

"update:addressbooks":
cmds:
- task: "update:addressbooks:mainnet"
- task: "update:addressbooks:testnet"
- task: "update:addressbooks:previewnet"
- task: "update:addressbooks:mainnet"
- task: "update:addressbooks:testnet"
- task: "update:addressbooks:previewnet"

update:
cmds:
- task: "update:proto"
- task: "update:snapshots"
- task: "update:addressbooks"
- task: "update:proto"
- task: "update:snapshots"
- task: "update:addressbooks"

publish:
env:
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id "com.github.ben-manes.versions" version "0.47.0"

id "jacoco"
id "org.sonarqube" version "4.2.1.3168"
id "org.sonarqube" version "4.3.0.3225"

id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
}
Expand Down
2 changes: 1 addition & 1 deletion example-android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation 'com.hedera.hashgraph:sdk:2.25.0'
implementation 'com.hedera.hashgraph:sdk:2.26.0'

implementation 'org.slf4j:slf4j-simple:2.0.7'
implementation 'io.grpc:grpc-okhttp:1.49.2'
Expand Down
4 changes: 2 additions & 2 deletions example-android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.8.22'
ext.kotlin_version = '1.9.0'

repositories {
google()
Expand All @@ -10,7 +10,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:8.0.2'
classpath 'com.android.tools.build:gradle:8.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.quittle:android-emulator-plugin:0.4.5'

Expand Down
97 changes: 97 additions & 0 deletions examples/src/main/java/ContractNoncesExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2020 - 2022 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.
*
*/

import com.hedera.hashgraph.sdk.AccountId;
import com.hedera.hashgraph.sdk.Client;
import com.hedera.hashgraph.sdk.ContractCreateTransaction;
import com.hedera.hashgraph.sdk.ContractDeleteTransaction;
import com.hedera.hashgraph.sdk.ContractId;
import com.hedera.hashgraph.sdk.ContractNonceInfo;
import com.hedera.hashgraph.sdk.FileCreateTransaction;
import com.hedera.hashgraph.sdk.FileId;
import com.hedera.hashgraph.sdk.Hbar;
import com.hedera.hashgraph.sdk.PrecheckStatusException;
import com.hedera.hashgraph.sdk.PrivateKey;
import com.hedera.hashgraph.sdk.ReceiptStatusException;
import com.hedera.hashgraph.sdk.Status;
import com.hedera.hashgraph.sdk.TransactionReceipt;
import com.hedera.hashgraph.sdk.TransactionResponse;
import io.github.cdimascio.dotenv.Dotenv;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeoutException;

public final class ContractNoncesExample {

// see `.env.sample` in the repository root for how to specify these values
// or set environment variables with the same names
private static final AccountId OPERATOR_ID = AccountId.fromString(
Objects.requireNonNull(Dotenv.load().get("OPERATOR_ID")));
private static final PrivateKey OPERATOR_KEY = PrivateKey.fromString(
Objects.requireNonNull(Dotenv.load().get("OPERATOR_KEY")));
// HEDERA_NETWORK defaults to testnet if not specified in dotenv
private static final String HEDERA_NETWORK = Dotenv.load().get("HEDERA_NETWORK", "previewnet");
private static final String SMART_CONTRACT_BYTECODE = "6080604052348015600f57600080fd5b50604051601a90603b565b604051809103906000f0801580156035573d6000803e3d6000fd5b50506047565b605c8061009483390190565b603f806100556000396000f3fe6080604052600080fdfea2646970667358221220a20122cbad3457fedcc0600363d6e895f17048f5caa4afdab9e655123737567d64736f6c634300081200336080604052348015600f57600080fd5b50603f80601d6000396000f3fe6080604052600080fdfea264697066735822122053dfd8835e3dc6fedfb8b4806460b9b7163f8a7248bac510c6d6808d9da9d6d364736f6c63430008120033";

private ContractNoncesExample() {
}

public static void main(String[] args) throws TimeoutException, PrecheckStatusException, ReceiptStatusException {
Client client = Client.forName(HEDERA_NETWORK);

// Defaults the operator account ID and key such that all generated transactions will be paid for
// by this account and be signed by this key
client.setOperator(OPERATOR_ID, OPERATOR_KEY);

TransactionResponse fileCreateTxResponse = new FileCreateTransaction().setKeys(OPERATOR_KEY)
.setContents(SMART_CONTRACT_BYTECODE).setMaxTransactionFee(new Hbar(2)) // 2 HBAR
.execute(client);

TransactionReceipt fileCreateTxReceipt = fileCreateTxResponse.getReceipt(client);
FileId newFileId = fileCreateTxReceipt.fileId;

TransactionResponse contractCreateTxResponse = new ContractCreateTransaction().setAdminKey(OPERATOR_KEY)
.setGas(100000).setBytecodeFileId(newFileId)
.setContractMemo("[e2e::ContractADeploysContractBInConstructor]").execute(client);

TransactionReceipt contractCreateTxReceipt = contractCreateTxResponse.getReceipt(client);

ContractId contractId = contractCreateTxReceipt.contractId;

List<ContractNonceInfo> contractNonces = contractCreateTxResponse.getRecord(
client).contractFunctionResult.contractNonces;

System.out.println("contractNonces = " + contractNonces);

// now delete the contract
TransactionReceipt contractDeleteResult = new ContractDeleteTransaction()
.setContractId(contractId)
.setTransferAccountId(contractCreateTxReceipt.transactionId.accountId)
.setMaxTransactionFee(new Hbar(1))
.execute(client)
.getReceipt(client);

if (contractDeleteResult.status != Status.SUCCESS) {
System.out.println("error deleting contract: " + contractDeleteResult.status);
return;
}
System.out.println("Contract successfully deleted");
}
}
12 changes: 6 additions & 6 deletions sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "idea"
id "signing"
id "maven-publish"
id "com.google.protobuf" version "0.9.3"
id "com.google.protobuf" version "0.9.4"
id "com.github.spotbugs" version "5.0.14"
}

Expand Down Expand Up @@ -40,7 +40,7 @@ dependencies {
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
implementation 'org.slf4j:slf4j-api:2.0.7'

implementation "io.grpc:grpc-core:1.56.1"
implementation "io.grpc:grpc-core:1.57.0"
implementation "io.grpc:grpc-stub:1.56.1"

implementation "com.google.code.gson:gson:2.10.1"
Expand All @@ -49,8 +49,8 @@ dependencies {

testImplementation "org.assertj:assertj-core:3.24.2"
testImplementation "io.github.json-snapshot:json-snapshot:1.0.17"
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.9.3"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.9.3"
testImplementation "org.junit.jupiter:junit-jupiter-engine:5.10.0"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.10.0"

testRuntimeOnly "org.slf4j:slf4j-simple:2.0.7"
testRuntimeOnly "io.grpc:grpc-netty-shaded:1.56.1"
Expand All @@ -63,11 +63,11 @@ dependencies {
// https://github.com/google/protobuf-gradle-plugin
protobuf {
protoc {
artifact = "com.google.protobuf:protoc:3.23.2"
artifact = "com.google.protobuf:protoc:3.23.4"
}
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:1.56.1"
artifact = "io.grpc:protoc-gen-grpc-java:1.57.0"
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/src/integrationTest/java/ContractExecuteIntegrationTest.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

import com.google.errorprone.annotations.Var;
import com.hedera.hashgraph.sdk.ContractCreateTransaction;
import com.hedera.hashgraph.sdk.ContractDeleteTransaction;
import com.hedera.hashgraph.sdk.ContractExecuteTransaction;
import com.hedera.hashgraph.sdk.ContractFunctionParameters;
import com.hedera.hashgraph.sdk.FileCreateTransaction;
import com.hedera.hashgraph.sdk.FileDeleteTransaction;
import com.hedera.hashgraph.sdk.PrecheckStatusException;
import com.hedera.hashgraph.sdk.ReceiptStatusException;
import com.hedera.hashgraph.sdk.Status;
import java.util.Objects;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.util.Objects;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

public class ContractExecuteIntegrationTest {
private static final String SMART_CONTRACT_BYTECODE = "608060405234801561001057600080fd5b506040516104d73803806104d78339818101604052602081101561003357600080fd5b810190808051604051939291908464010000000082111561005357600080fd5b90830190602082018581111561006857600080fd5b825164010000000081118282018810171561008257600080fd5b82525081516020918201929091019080838360005b838110156100af578181015183820152602001610097565b50505050905090810190601f1680156100dc5780820380516001836020036101000a031916815260200191505b506040525050600080546001600160a01b0319163317905550805161010890600190602084019061010f565b50506101aa565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061015057805160ff191683800117855561017d565b8280016001018555821561017d579182015b8281111561017d578251825591602001919060010190610162565b5061018992915061018d565b5090565b6101a791905b808211156101895760008155600101610193565b90565b61031e806101b96000396000f3fe608060405234801561001057600080fd5b50600436106100415760003560e01c8063368b87721461004657806341c0e1b5146100ee578063ce6d41de146100f6575b600080fd5b6100ec6004803603602081101561005c57600080fd5b81019060208101813564010000000081111561007757600080fd5b82018360208201111561008957600080fd5b803590602001918460018302840111640100000000831117156100ab57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550610173945050505050565b005b6100ec6101a2565b6100fe6101ba565b6040805160208082528351818301528351919283929083019185019080838360005b83811015610138578181015183820152602001610120565b50505050905090810190601f1680156101655780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6000546001600160a01b0316331461018a5761019f565b805161019d906001906020840190610250565b505b50565b6000546001600160a01b03163314156101b85733ff5b565b60018054604080516020601f600260001961010087891615020190951694909404938401819004810282018101909252828152606093909290918301828280156102455780601f1061021a57610100808354040283529160200191610245565b820191906000526020600020905b81548152906001019060200180831161022857829003601f168201915b505050505090505b90565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061029157805160ff19168380011785556102be565b828001600101855582156102be579182015b828111156102be5782518255916020019190600101906102a3565b506102ca9291506102ce565b5090565b61024d91905b808211156102ca57600081556001016102d456fea264697066735822122084964d4c3f6bc912a9d20e14e449721012d625aa3c8a12de41ae5519752fc89064736f6c63430006000033";

Expand Down Expand Up @@ -149,7 +149,7 @@ void cannotExecuteContractWhenGasIsNotSet() throws Exception {
.contractId
);

assertThatExceptionOfType(ReceiptStatusException.class).isThrownBy(() -> {
assertThatExceptionOfType(PrecheckStatusException.class).isThrownBy(() -> {
new ContractExecuteTransaction()
.setContractId(contractId)
.setFunction("setMessage", new ContractFunctionParameters().addString("new message"))
Expand Down
Loading

0 comments on commit 45c4e17

Please sign in to comment.