Skip to content

Commit

Permalink
chore: rename packages to hiero (#2141)
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Ivanov <[email protected]>
  • Loading branch information
0xivanov authored Dec 18, 2024
1 parent 03d5e11 commit dcddf04
Show file tree
Hide file tree
Showing 1,190 changed files with 58,783 additions and 66,177 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ jobs:
env:
NEXUS_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
NEXUS_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
run: ./gradlew releaseMavenCentral -PpublishingPackageGroup=com.hedera.hashgraph -PpublishSigningEnabled=true --scan --no-configuration-cache
run: ./gradlew releaseMavenCentral -PpublishingPackageGroup=org.hiero -PpublishSigningEnabled=true --scan --no-configuration-cache
20 changes: 1 addition & 19 deletions example-android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0

plugins {
id("com.android.application")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.android_example

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.android_example.ui.main

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.android_example.ui.main

import android.os.Bundle
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.android_example.ui.main

import android.widget.TextView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.android_example.ui.main

import androidx.fragment.app.FragmentActivity
Expand Down
20 changes: 1 addition & 19 deletions example-android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0

plugins {
id("com.android.application") version "8.2.2" apply false
Expand Down
20 changes: 1 addition & 19 deletions example-android/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0

pluginManagement {
repositories {
Expand Down
1 change: 1 addition & 0 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dependencyAnalysis {
}

dependencies.constraints {
implementation("com.google.guava:guava:33.3.1-android")
implementation("io.github.cdimascio:dotenv-java:3.0.2")
implementation("com.hedera.hashgraph:sdk:2.46.0")
implementation("com.hedera.hashgraph:sdk-full:2.46.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
/*-
*
* Hedera Java SDK
*
* Copyright (C) 2022 - 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.
*
*/
// SPDX-License-Identifier: Apache-2.0
package com.hedera.hashgraph.sdk.examples;

import com.google.gson.Gson;
Expand All @@ -36,9 +18,7 @@
import com.hedera.hashgraph.sdk.Status;
import com.hedera.hashgraph.sdk.TransactionId;
import com.hedera.hashgraph.sdk.TransactionRecord;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
Expand All @@ -48,7 +28,6 @@
import java.util.function.Function;
import java.util.function.Supplier;


/*
ContractHelper declutters PrecompileExample.java
Expand Down Expand Up @@ -78,13 +57,14 @@ public class ContractHelper {

public static String getBytecodeHex(String filename) throws IOException {
try (Reader reader = new InputStreamReader(
Optional.ofNullable(ContractHelper.class.getResourceAsStream(filename))
.orElseThrow(() -> new RuntimeException("Failed to find: " + filename)),
StandardCharsets.UTF_8)) {
Optional.ofNullable(ContractHelper.class.getResourceAsStream(filename))
.orElseThrow(() -> new RuntimeException("Failed to find: " + filename)),
StandardCharsets.UTF_8)) {

JsonObject json = new Gson().fromJson(reader, JsonObject.class);
JsonElement bytecodeElement = Optional.ofNullable(json.has("object") ? json.get("object") : json.get("bytecode"))
.orElseThrow(() -> new RuntimeException("No bytecode or object found in json."));
JsonElement bytecodeElement = Optional.ofNullable(
json.has("object") ? json.get("object") : json.get("bytecode"))
.orElseThrow(() -> new RuntimeException("No bytecode or object found in json."));

if (bytecodeElement.isJsonObject()) {
bytecodeElement = bytecodeElement.getAsJsonObject().get("object");
Expand All @@ -93,22 +73,20 @@ public static String getBytecodeHex(String filename) throws IOException {
}
}

public ContractHelper(
String filename,
ContractFunctionParameters constructorParameters,
Client client
) throws PrecheckStatusException, TimeoutException, ReceiptStatusException, IOException {
public ContractHelper(String filename, ContractFunctionParameters constructorParameters, Client client)
throws PrecheckStatusException, TimeoutException, ReceiptStatusException, IOException {
contractId = Objects.requireNonNull(new ContractCreateFlow()
.setBytecode(getBytecodeHex(filename))
.setMaxChunks(30)
.setGas(8_000_000)
.setConstructorParameters(constructorParameters)
.execute(client)
.getReceipt(client)
.contractId);
.setBytecode(getBytecodeHex(filename))
.setMaxChunks(30)
.setGas(8_000_000)
.setConstructorParameters(constructorParameters)
.execute(client)
.getReceipt(client)
.contractId);
}

public ContractHelper setResultValidatorForStep(int stepIndex, Function<ContractFunctionResult, Boolean> validator) {
public ContractHelper setResultValidatorForStep(
int stepIndex, Function<ContractFunctionResult, Boolean> validator) {
stepResultValidators.put(stepIndex, validator);
return this;
}
Expand Down Expand Up @@ -146,17 +124,17 @@ public ContractHelper setStepLogic(int stepIndex, Consumer<String> stepLogic) {

private Function<ContractFunctionResult, Boolean> getResultValidator(int stepIndex) {
return stepResultValidators.getOrDefault(
stepIndex,
// if no custom validator is given, assume that the step returns a response code which ought to be SUCCESS
contractFunctionResult -> {
Status responseStatus = Status.fromResponseCode(contractFunctionResult.getInt32(0));
boolean isValid = responseStatus == Status.SUCCESS;
if (!isValid) {
System.out.println("Encountered invalid response status " + responseStatus);
}
return isValid;
}
);
stepIndex,
// if no custom validator is given, assume that the step returns a response code which ought to be
// SUCCESS
contractFunctionResult -> {
Status responseStatus = Status.fromResponseCode(contractFunctionResult.getInt32(0));
boolean isValid = responseStatus == Status.SUCCESS;
if (!isValid) {
System.out.println("Encountered invalid response status " + responseStatus);
}
return isValid;
});
}

private Supplier<ContractFunctionParameters> getParameterSupplier(int stepIndex) {
Expand All @@ -171,24 +149,20 @@ private List<PrivateKey> getSigners(int stepIndex) {
return stepSigners.getOrDefault(stepIndex, Collections.emptyList());
}

public ContractHelper executeSteps(
int firstStepToExecute,
int lastStepToExecute,
Client client
) throws Exception {
public ContractHelper executeSteps(int firstStepToExecute, int lastStepToExecute, Client client) throws Exception {
for (int stepIndex = firstStepToExecute; stepIndex <= lastStepToExecute; stepIndex++) {
System.out.println("Attempting to execute step " + stepIndex);
ContractExecuteTransaction tx = new ContractExecuteTransaction()
.setContractId(contractId)
.setGas(10_000_000);
ContractExecuteTransaction tx =
new ContractExecuteTransaction().setContractId(contractId).setGas(10_000_000);

Hbar payableAmount = getPayableAmount(stepIndex);
if (payableAmount != null) {
tx.setPayableAmount(payableAmount);
}

String functionName = "step" + stepIndex;
ContractFunctionParameters parameters = getParameterSupplier(stepIndex).get();
ContractFunctionParameters parameters =
getParameterSupplier(stepIndex).get();
if (parameters != null) {
tx.setFunction(functionName, parameters);
} else {
Expand All @@ -205,14 +179,13 @@ public ContractHelper executeSteps(
tx.sign(signer);
}

TransactionRecord record = tx
.execute(client)
.setValidateStatus(false)
.getRecord(client);
TransactionRecord record =
tx.execute(client).setValidateStatus(false).getRecord(client);

try {
if (record.receipt.status != Status.SUCCESS) {
throw new Exception("transaction receipt yielded unsuccessful response code " + record.receipt.status);
throw new Exception(
"transaction receipt yielded unsuccessful response code " + record.receipt.status);
}

ContractFunctionResult functionResult = Objects.requireNonNull(record.contractFunctionResult);
Expand All @@ -224,12 +197,14 @@ public ContractHelper executeSteps(
}

if (getResultValidator(stepIndex).apply(functionResult)) {
System.out.println("step " + stepIndex + " completed, and returned valid result. (TransactionId \"" + record.transactionId + "\")");
System.out.println("step " + stepIndex + " completed, and returned valid result. (TransactionId \""
+ record.transactionId + "\")");
} else {
throw new Exception("returned invalid result");
}
} catch (Throwable error) {
throw new Exception("Error occurred in step " + stepIndex + ": " + error.getMessage() + "\n" + "Transaction record: " + record);
throw new Exception("Error occurred in step " + stepIndex + ": " + error.getMessage() + "\n"
+ "Transaction record: " + record);
}

// otherwise will meet local-node throttle
Expand Down
Loading

0 comments on commit dcddf04

Please sign in to comment.