From 7dfbafbe8b23134435373add95a6587de780227a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:07:53 +0000 Subject: [PATCH 01/18] chore(deps): bump codecov/codecov-action from 4.6.0 to 5.0.0 (#2081) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a77dab0d3..6ba902783 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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@968872560f81e7bdde9272853e65f2507c0eca7c # v5.0.0 - name: Stop the local node run: npx @hashgraph/hedera-local stop From 4abf8a4eec5c16c39fb07ef26d17723fb54691e2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:12:50 +0200 Subject: [PATCH 02/18] chore(deps): bump codecov/codecov-action from 5.0.0 to 5.0.2 (#2082) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ba902783..cc8442f79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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@968872560f81e7bdde9272853e65f2507c0eca7c # v5.0.0 + uses: codecov/codecov-action@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2 - name: Stop the local node run: npx @hashgraph/hedera-local stop From b8ae85c7dbe9c1a987352ba7573be9d2e9a5f678 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Mon, 18 Nov 2024 15:47:32 +0200 Subject: [PATCH 03/18] feat(TCK): `updateToken` method (#2084) Signed-off-by: Ivan Ivanov --- .../hashgraph/sdk/TokenUpdateTransaction.java | 15 +++ .../tck/methods/sdk/TokenService.java | 105 ++++++++++++++++++ .../methods/sdk/param/TokenUpdateParams.java | 103 +++++++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenUpdateParams.java diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/TokenUpdateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/TokenUpdateTransaction.java index 39a27fba0..ef130ff01 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/TokenUpdateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/TokenUpdateTransaction.java @@ -142,6 +142,8 @@ public class TokenUpdateTransaction extends Transaction */ @Nullable private Instant expirationTime = null; + private Duration expirationTimeDuration = null; + /** * The new interval at which the auto-renew account will be charged to * extend the token's expiry. @@ -488,6 +490,16 @@ public TokenUpdateTransaction setExpirationTime(Instant expirationTime) { requireNotFrozen(); autoRenewPeriod = null; this.expirationTime = expirationTime; + this.expirationTimeDuration = null; + return this; + } + + public TokenUpdateTransaction setExpirationTime(Duration expirationTime) { + Objects.requireNonNull(expirationTime); + requireNotFrozen(); + autoRenewPeriod = null; + this.expirationTime = null; + this.expirationTimeDuration = expirationTime; return this; } @@ -717,6 +729,9 @@ TokenUpdateTransactionBody.Builder build() { if (expirationTime != null) { builder.setExpiry(InstantConverter.toProtobuf(expirationTime)); } + if (expirationTimeDuration != null) { + builder.setExpiry(InstantConverter.toProtobuf(expirationTimeDuration)); + } if (autoRenewPeriod != null) { builder.setAutoRenewPeriod(DurationConverter.toProtobuf(autoRenewPeriod)); } diff --git a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java index c2bcbc861..b49a5cf7e 100644 --- a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java +++ b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java @@ -30,11 +30,13 @@ import com.hedera.hashgraph.sdk.TokenId; import com.hedera.hashgraph.sdk.TokenSupplyType; import com.hedera.hashgraph.sdk.TokenType; +import com.hedera.hashgraph.sdk.TokenUpdateTransaction; import com.hedera.hashgraph.sdk.TransactionReceipt; import com.hedera.hashgraph.tck.annotation.JSONRPC2Method; import com.hedera.hashgraph.tck.annotation.JSONRPC2Service; import com.hedera.hashgraph.tck.methods.AbstractJSONRPC2Service; import com.hedera.hashgraph.tck.methods.sdk.param.TokenCreateParams; +import com.hedera.hashgraph.tck.methods.sdk.param.TokenUpdateParams; import com.hedera.hashgraph.tck.methods.sdk.response.TokenResponse; import com.hedera.hashgraph.tck.util.KeyUtils; import java.time.Duration; @@ -233,4 +235,107 @@ public TokenResponse createToken(final TokenCreateParams params) throws Exceptio return new TokenResponse(tokenId, transactionReceipt.status); } + + @JSONRPC2Method("updateToken") + public TokenResponse updateToken(final TokenUpdateParams params) throws Exception { + TokenUpdateTransaction tokenUpdateTransaction = new TokenUpdateTransaction(); + + params.getTokenId().ifPresent(tokenId -> tokenUpdateTransaction.setTokenId(TokenId.fromString(tokenId))); + + params.getAdminKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setAdminKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getKycKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setKycKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getFreezeKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setFreezeKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getWipeKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setWipeKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getSupplyKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setSupplyKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getFeeScheduleKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setFeeScheduleKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getPauseKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setPauseKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getMetadataKey().ifPresent(key -> { + try { + tokenUpdateTransaction.setMetadataKey(KeyUtils.getKeyFromString(key)); + } catch (InvalidProtocolBufferException e) { + throw new IllegalArgumentException(e); + } + }); + + params.getName().ifPresent(tokenUpdateTransaction::setTokenName); + params.getSymbol().ifPresent(tokenUpdateTransaction::setTokenSymbol); + + params.getTreasuryAccountId() + .ifPresent(treasuryAccountId -> + tokenUpdateTransaction.setTreasuryAccountId(AccountId.fromString(treasuryAccountId))); + + params.getExpirationTime() + .ifPresent(expirationTime -> + tokenUpdateTransaction.setExpirationTime(Duration.ofSeconds(Long.parseLong(expirationTime)))); + + params.getAutoRenewAccountId() + .ifPresent(autoRenewAccountId -> + tokenUpdateTransaction.setAutoRenewAccountId(AccountId.fromString(autoRenewAccountId))); + + params.getAutoRenewPeriod() + .ifPresent(autoRenewPeriodSeconds -> tokenUpdateTransaction.setAutoRenewPeriod( + Duration.ofSeconds(Long.parseLong(autoRenewPeriodSeconds)))); + + params.getMemo().ifPresent(tokenUpdateTransaction::setTokenMemo); + + params.getMetadata().ifPresent(metadata -> tokenUpdateTransaction.setTokenMetadata(metadata.getBytes())); + + params.getCommonTransactionParams() + .ifPresent(commonTransactionParams -> + commonTransactionParams.fillOutTransaction(tokenUpdateTransaction, sdkService.getClient())); + + TransactionReceipt transactionReceipt = + tokenUpdateTransaction.execute(sdkService.getClient()).getReceipt(sdkService.getClient()); + + return new TokenResponse("", transactionReceipt.status); + } } diff --git a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenUpdateParams.java b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenUpdateParams.java new file mode 100644 index 000000000..01902fc8e --- /dev/null +++ b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenUpdateParams.java @@ -0,0 +1,103 @@ +/*- + * + * Hedera Java SDK + * + * Copyright (C) 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.tck.methods.sdk.param; + +import com.hedera.hashgraph.tck.methods.JSONRPC2Param; +import java.util.Map; +import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.minidev.json.JSONObject; + +/** + * TokenUpdateParams for token update method + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class TokenUpdateParams extends JSONRPC2Param { + private Optional tokenId; + private Optional name; + private Optional symbol; + private Optional treasuryAccountId; + private Optional adminKey; + private Optional kycKey; + private Optional freezeKey; + private Optional wipeKey; + private Optional supplyKey; + private Optional feeScheduleKey; + private Optional pauseKey; + private Optional metadataKey; + private Optional expirationTime; + private Optional autoRenewAccountId; + private Optional autoRenewPeriod; + private Optional memo; + private Optional metadata; + private Optional commonTransactionParams; + + @Override + public JSONRPC2Param parse(Map jrpcParams) throws Exception { + var parsedTokenId = Optional.ofNullable((String) jrpcParams.get("tokenId")); + var parsedName = Optional.ofNullable((String) jrpcParams.get("name")); + var parsedSymbol = Optional.ofNullable((String) jrpcParams.get("symbol")); + var parsedTreasuryAccountId = Optional.ofNullable((String) jrpcParams.get("treasuryAccountId")); + var parsedAdminKey = Optional.ofNullable((String) jrpcParams.get("adminKey")); + var parsedKycKey = Optional.ofNullable((String) jrpcParams.get("kycKey")); + var parsedFreezeKey = Optional.ofNullable((String) jrpcParams.get("freezeKey")); + var parsedWipeKey = Optional.ofNullable((String) jrpcParams.get("wipeKey")); + var parsedSupplyKey = Optional.ofNullable((String) jrpcParams.get("supplyKey")); + var parsedFeeScheduleKey = Optional.ofNullable((String) jrpcParams.get("feeScheduleKey")); + var parsedPauseKey = Optional.ofNullable((String) jrpcParams.get("pauseKey")); + var parsedMetadataKey = Optional.ofNullable((String) jrpcParams.get("metadataKey")); + var parsedExpirationTime = Optional.ofNullable((String) jrpcParams.get("expirationTime")); + var parsedAutoRenewAccountId = Optional.ofNullable((String) jrpcParams.get("autoRenewAccountId")); + var parsedAutoRenewPeriod = Optional.ofNullable((String) jrpcParams.get("autoRenewPeriod")); + var parsedMemo = Optional.ofNullable((String) jrpcParams.get("memo")); + var parsedMetadata = Optional.ofNullable((String) jrpcParams.get("metadata")); + + Optional parsedCommonTransactionParams = Optional.empty(); + if (jrpcParams.containsKey("commonTransactionParams")) { + JSONObject jsonObject = (JSONObject) jrpcParams.get("commonTransactionParams"); + parsedCommonTransactionParams = Optional.of(CommonTransactionParams.parse(jsonObject)); + } + + return new TokenUpdateParams( + parsedTokenId, + parsedName, + parsedSymbol, + parsedTreasuryAccountId, + parsedAdminKey, + parsedKycKey, + parsedFreezeKey, + parsedWipeKey, + parsedSupplyKey, + parsedFeeScheduleKey, + parsedPauseKey, + parsedMetadataKey, + parsedExpirationTime, + parsedAutoRenewAccountId, + parsedAutoRenewPeriod, + parsedMemo, + parsedMetadata, + parsedCommonTransactionParams); + } +} From ae475c82a471fce766cfabc74ae73254493a53d8 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Tue, 19 Nov 2024 09:31:31 +0200 Subject: [PATCH 04/18] feat: init client with mirror network (#2085) Signed-off-by: Ivan Ivanov --- ...tializeClientWithMirrorNetworkExample.java | 92 +++++++++++++++++++ ...com.hedera.gradle.examples.java.gradle.kts | 1 + .../java/com/hedera/hashgraph/sdk/Client.java | 23 ++++- .../integration/ClientIntegrationTest.java | 14 +++ 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 examples/src/main/java/com/hedera/hashgraph/sdk/examples/InitializeClientWithMirrorNetworkExample.java diff --git a/examples/src/main/java/com/hedera/hashgraph/sdk/examples/InitializeClientWithMirrorNetworkExample.java b/examples/src/main/java/com/hedera/hashgraph/sdk/examples/InitializeClientWithMirrorNetworkExample.java new file mode 100644 index 000000000..20ba0e68b --- /dev/null +++ b/examples/src/main/java/com/hedera/hashgraph/sdk/examples/InitializeClientWithMirrorNetworkExample.java @@ -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. + *

+ * 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); + } +} diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts index 220ceb189..e90786ea4 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.examples.java.gradle.kts @@ -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 -> diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java index da66b5aa8..957b14ba5 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/Client.java @@ -185,6 +185,24 @@ public static Client forNetwork(Map 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 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. * @@ -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(); @@ -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); } } diff --git a/sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/ClientIntegrationTest.java b/sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/ClientIntegrationTest.java index 5ec000e6b..08da7ffbb 100644 --- a/sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/ClientIntegrationTest.java +++ b/sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/ClientIntegrationTest.java @@ -21,6 +21,7 @@ import com.hedera.hashgraph.sdk.*; import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.time.Duration; @@ -248,4 +249,17 @@ void pingAllAsync() throws Exception { } } + + @Test + @DisplayName("`forMirrorNetwork()`") + void testClientInitWithMirrorNetwork() throws Exception { + var mirrorNetworkString = "testnet.mirrornode.hedera.com:443"; + var client = Client.forMirrorNetwork(List.of(mirrorNetworkString)); + var mirrorNetwork = client.getMirrorNetwork(); + + assertThat(mirrorNetwork).hasSize(1); + assertThat(mirrorNetwork.get(0)).isEqualTo(mirrorNetworkString); + assertThat(client.getNetwork()).isNotNull(); + assertThat(client.getNetwork()).isNotEmpty(); + } } From 2c9d852fe8d8c78c239a5fb5073d4564be2fa899 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 04:25:08 -0600 Subject: [PATCH 05/18] chore(deps): bump step-security/harden-runner from 2.10.1 to 2.10.2 (#2087) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 8 ++++---- .github/workflows/pages.yml | 2 +- .github/workflows/release-artifacts.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cc8442f79..9ae376534 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index b7499cebf..75a3caf4c 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -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 diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 1d1731fb4..8fd47f4ca 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -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 @@ -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 From 554c71c1452c188ba90b15cd7389133743ea0278 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 04:25:45 -0600 Subject: [PATCH 06/18] chore(deps): bump gradle/actions from 4.2.0 to 4.2.1 (#2086) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 8 ++++---- .github/workflows/pages.yml | 2 +- .github/workflows/release-artifacts.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ae376534..9437c112d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 75a3caf4c..e84271725 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -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 diff --git a/.github/workflows/release-artifacts.yml b/.github/workflows/release-artifacts.yml index 8fd47f4ca..a04f48204 100644 --- a/.github/workflows/release-artifacts.yml +++ b/.github/workflows/release-artifacts.yml @@ -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 @@ -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 From 8c89cb3c71d6b56fb81d9ebf98ba17c3164116e0 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Wed, 20 Nov 2024 11:16:41 +0200 Subject: [PATCH 07/18] feat(TCK): Implement `tokenDelete` (#2088) Signed-off-by: Ivan Ivanov --- .../tck/methods/sdk/TokenService.java | 18 +++++++ .../methods/sdk/param/TokenDeleteParams.java | 52 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenDeleteParams.java diff --git a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java index b49a5cf7e..832678f27 100644 --- a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java +++ b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/TokenService.java @@ -27,6 +27,7 @@ import com.hedera.hashgraph.sdk.CustomRoyaltyFee; import com.hedera.hashgraph.sdk.Status; import com.hedera.hashgraph.sdk.TokenCreateTransaction; +import com.hedera.hashgraph.sdk.TokenDeleteTransaction; import com.hedera.hashgraph.sdk.TokenId; import com.hedera.hashgraph.sdk.TokenSupplyType; import com.hedera.hashgraph.sdk.TokenType; @@ -36,6 +37,7 @@ import com.hedera.hashgraph.tck.annotation.JSONRPC2Service; import com.hedera.hashgraph.tck.methods.AbstractJSONRPC2Service; import com.hedera.hashgraph.tck.methods.sdk.param.TokenCreateParams; +import com.hedera.hashgraph.tck.methods.sdk.param.TokenDeleteParams; import com.hedera.hashgraph.tck.methods.sdk.param.TokenUpdateParams; import com.hedera.hashgraph.tck.methods.sdk.response.TokenResponse; import com.hedera.hashgraph.tck.util.KeyUtils; @@ -338,4 +340,20 @@ public TokenResponse updateToken(final TokenUpdateParams params) throws Exceptio return new TokenResponse("", transactionReceipt.status); } + + @JSONRPC2Method("deleteToken") + public TokenResponse deleteToken(final TokenDeleteParams params) throws Exception { + TokenDeleteTransaction tokenDeleteTransaction = new TokenDeleteTransaction(); + + params.getTokenId().ifPresent(tokenId -> tokenDeleteTransaction.setTokenId(TokenId.fromString(tokenId))); + + params.getCommonTransactionParams() + .ifPresent(commonTransactionParams -> + commonTransactionParams.fillOutTransaction(tokenDeleteTransaction, sdkService.getClient())); + + TransactionReceipt transactionReceipt = + tokenDeleteTransaction.execute(sdkService.getClient()).getReceipt(sdkService.getClient()); + + return new TokenResponse("", transactionReceipt.status); + } } diff --git a/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenDeleteParams.java b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenDeleteParams.java new file mode 100644 index 000000000..b65dd5d7e --- /dev/null +++ b/tck/src/main/java/com/hedera/hashgraph/tck/methods/sdk/param/TokenDeleteParams.java @@ -0,0 +1,52 @@ +/*- + * + * Hedera Java SDK + * + * Copyright (C) 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.tck.methods.sdk.param; + +import com.hedera.hashgraph.tck.methods.JSONRPC2Param; +import java.util.Map; +import java.util.Optional; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import net.minidev.json.JSONObject; + +/** + * TokenDeleteParams for token delete method + */ +@Getter +@AllArgsConstructor +@NoArgsConstructor +public class TokenDeleteParams extends JSONRPC2Param { + private Optional tokenId; + private Optional commonTransactionParams; + + @Override + public JSONRPC2Param parse(Map jrpcParams) throws Exception { + var parsedTokenId = Optional.ofNullable((String) jrpcParams.get("tokenId")); + Optional parsedCommonTransactionParams = Optional.empty(); + if (jrpcParams.containsKey("commonTransactionParams")) { + JSONObject jsonObject = (JSONObject) jrpcParams.get("commonTransactionParams"); + parsedCommonTransactionParams = Optional.of(CommonTransactionParams.parse(jsonObject)); + } + + return new TokenDeleteParams(parsedTokenId, parsedCommonTransactionParams); + } +} From 6dc0f00b49e6bea64212c5c657853c786bf9ba61 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 07:05:39 -0600 Subject: [PATCH 08/18] chore(deps): bump codecov/codecov-action from 5.0.2 to 5.0.4 (#2093) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9437c112d..f157a8f43 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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@5c47607acb93fed5485fdbf7232e8a31425f672a # v5.0.2 + uses: codecov/codecov-action@985343d70564a82044c1b7fcb84c2fa05405c1a2 # v5.0.4 - name: Stop the local node run: npx @hashgraph/hedera-local stop From c8a56042e24c20c582e5806b5e7eacd2f67606ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 16:21:24 +0200 Subject: [PATCH 09/18] chore(deps): bump com.esaulpaugh:headlong from 12.1.0 to 12.3.3 in /sdk-dependency-versions (#2059) Signed-off-by: dependabot[bot] Signed-off-by: Jendrik Johannes Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jendrik Johannes --- .../src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts | 2 +- sdk-dependency-versions/build.gradle.kts | 2 +- sdk-full/src/main/java/module-info.java | 2 +- sdk/src/main/java/module-info.java | 2 +- sdk/src/testIntegration/java/module-info.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts index 6282658cb..92ff97535 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts @@ -62,7 +62,7 @@ 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.guava:failureaccess", "com.google.common.util.concurrent.internal") diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts index 220dd22b0..9a302c381 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/sdk-dependency-versions/build.gradle.kts @@ -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") { diff --git a/sdk-full/src/main/java/module-info.java b/sdk-full/src/main/java/module-info.java index 515c7989e..b82a169e1 100644 --- a/sdk-full/src/main/java/module-info.java +++ b/sdk-full/src/main/java/module-info.java @@ -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; diff --git a/sdk/src/main/java/module-info.java b/sdk/src/main/java/module-info.java index d9f19f2fe..7dfbc187f 100644 --- a/sdk/src/main/java/module-info.java +++ b/sdk/src/main/java/module-info.java @@ -21,9 +21,9 @@ module com.hedera.hashgraph.sdk { 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.lite; requires io.grpc.stub; diff --git a/sdk/src/testIntegration/java/module-info.java b/sdk/src/testIntegration/java/module-info.java index 90228b96c..8fbf5e58a 100644 --- a/sdk/src/testIntegration/java/module-info.java +++ b/sdk/src/testIntegration/java/module-info.java @@ -20,7 +20,7 @@ open module com.hedera.hashgraph.sdk.test.integration { requires com.hedera.hashgraph.sdk; - requires headlong; + requires com.esaulpaugh.headlong; requires org.assertj.core; requires org.bouncycastle.provider; requires org.junit.jupiter.api; From 5f9966d3a18c84bd2006b31359f5ce9815275feb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:24:21 +0000 Subject: [PATCH 10/18] chore(deps): bump codecov/codecov-action from 5.0.4 to 5.0.7 (#2094) --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f157a8f43..baad0f33c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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@985343d70564a82044c1b7fcb84c2fa05405c1a2 # v5.0.4 + uses: codecov/codecov-action@015f24e6818733317a2da2edd6290ab26238649a # v5.0.7 - name: Stop the local node run: npx @hashgraph/hedera-local stop From 2f5d66a64561f5ebb0a286539fb296cacb5f87f9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 14:12:01 +0200 Subject: [PATCH 11/18] chore(deps): bump io.grpc:grpc-stub from 1.64.0 to 1.68.1 in /sdk-dependency-versions (#2060) Signed-off-by: dependabot[bot] Signed-off-by: Mihail Mihov Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Mihail Mihov --- .../main/kotlin/com.hedera.gradle.patch-modules.gradle.kts | 6 +++++- sdk-dependency-versions/build.gradle.kts | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts b/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts index 92ff97535..913408e8b 100644 --- a/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts +++ b/gradle/plugins/src/main/kotlin/com.hedera.gradle.patch-modules.gradle.kts @@ -64,7 +64,11 @@ extraJavaModuleInfo { 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() diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts index 9a302c381..21484406e 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/sdk-dependency-versions/build.gradle.kts @@ -49,7 +49,7 @@ dependencies.constraints { api("io.grpc:grpc-protobuf-lite:1.64.0") { 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") { From 2656bcdca364130895f94ffbdb5a7aab62bcc67b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:25:47 +0000 Subject: [PATCH 12/18] chore(deps): bump io.grpc:grpc-api from 1.64.0 to 1.68.1 in /sdk-dependency-versions (#2067) --- sdk-dependency-versions/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts index 21484406e..9d4c3f7f0 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/sdk-dependency-versions/build.gradle.kts @@ -37,7 +37,7 @@ 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") { From 129187492b75de5c1ed95ff261c186ae98117dde Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:26:23 +0000 Subject: [PATCH 13/18] chore(deps): bump io.grpc:grpc-protobuf from 1.64.0 to 1.68.1 in /sdk-dependency-versions (#2062) --- sdk-dependency-versions/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts index 9d4c3f7f0..b31119cbb 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/sdk-dependency-versions/build.gradle.kts @@ -43,10 +43,10 @@ dependencies.constraints { api("io.grpc:grpc-inprocess:1.64.0") { 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.68.1") { From 4db31313ef03ae69c2ac743ed0b669aaef8a09d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:26:40 +0000 Subject: [PATCH 14/18] chore(deps): bump io.grpc:grpc-protobuf-lite from 1.64.0 to 1.68.1 in /sdk-dependency-versions (#2061) From 4637da6e2b7916b3d6a3bfa81cceec6eccc994f8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2024 12:58:45 +0000 Subject: [PATCH 15/18] chore(deps): bump io.grpc:grpc-inprocess from 1.64.0 to 1.67.1 in /sdk-dependency-versions (#2083) --- sdk-dependency-versions/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk-dependency-versions/build.gradle.kts b/sdk-dependency-versions/build.gradle.kts index b31119cbb..ac383fd11 100644 --- a/sdk-dependency-versions/build.gradle.kts +++ b/sdk-dependency-versions/build.gradle.kts @@ -40,7 +40,7 @@ dependencies.constraints { 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.68.1") { From d719e27e024bce65f652d4e2a82e36883c79063b Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Fri, 22 Nov 2024 09:14:58 +0200 Subject: [PATCH 16/18] chore: fix serialize/deserialize for `NodeUpdate` and `NodeCreate` (#2092) Signed-off-by: Ivan Ivanov --- .../hashgraph/sdk/NodeCreateTransaction.java | 19 +++++------- .../hashgraph/sdk/NodeUpdateTransaction.java | 21 ++++++------- .../sdk/NodeCreateTransactionTest.java | 21 +++++++++++++ .../sdk/NodeUpdateTransactionTest.java | 31 ++++++++++++++++++- 4 files changed, 69 insertions(+), 23 deletions(-) diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeCreateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeCreateTransaction.java index 3f3be13b0..5779d3fe0 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeCreateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeCreateTransaction.java @@ -194,7 +194,6 @@ public AccountId getAccountId() { * @return {@code this} */ public NodeCreateTransaction setAccountId(AccountId accountId) { - Objects.requireNonNull(accountId); requireNotFrozen(); this.accountId = accountId; return this; @@ -215,7 +214,6 @@ public String getDescription() { */ public NodeCreateTransaction setDescription(String description) { requireNotFrozen(); - Objects.requireNonNull(description); this.description = description; return this; } @@ -288,7 +286,7 @@ public NodeCreateTransaction addServiceEndpoint(Endpoint serviceEndpoint) { */ @Nullable public byte[] getGossipCaCertificate() { - return gossipCaCertificate != null ? Arrays.copyOf(gossipCaCertificate, gossipCaCertificate.length) : null; + return gossipCaCertificate; } /** @@ -299,9 +297,8 @@ public byte[] getGossipCaCertificate() { * @return {@code this} */ public NodeCreateTransaction setGossipCaCertificate(byte[] gossipCaCertificate) { - Objects.requireNonNull(gossipCaCertificate); requireNotFrozen(); - this.gossipCaCertificate = Arrays.copyOf(gossipCaCertificate, gossipCaCertificate.length); + this.gossipCaCertificate = gossipCaCertificate; return this; } @@ -311,7 +308,7 @@ public NodeCreateTransaction setGossipCaCertificate(byte[] gossipCaCertificate) */ @Nullable public byte[] getGrpcCertificateHash() { - return grpcCertificateHash != null ? Arrays.copyOf(grpcCertificateHash, grpcCertificateHash.length) : null; + return grpcCertificateHash; } /** @@ -322,9 +319,8 @@ public byte[] getGrpcCertificateHash() { * @return {@code this} */ public NodeCreateTransaction setGrpcCertificateHash(byte[] grpcCertificateHash) { - Objects.requireNonNull(grpcCertificateHash); requireNotFrozen(); - this.grpcCertificateHash = Arrays.copyOf(grpcCertificateHash, grpcCertificateHash.length); + this.grpcCertificateHash = grpcCertificateHash; return this; } @@ -343,7 +339,6 @@ public Key getAdminKey() { * @return {@code this} */ public NodeCreateTransaction setAdminKey(Key adminKey) { - Objects.requireNonNull(adminKey); requireNotFrozen(); this.adminKey = adminKey; return this; @@ -406,9 +401,11 @@ void initFromTransactionBody() { serviceEndpoints.add(Endpoint.fromProtobuf(serviceEndpoint)); } - gossipCaCertificate = body.getGossipCaCertificate().toByteArray(); + var protobufGossipCert = body.getGossipCaCertificate(); + gossipCaCertificate = protobufGossipCert.equals(ByteString.empty()) ? null : protobufGossipCert.toByteArray(); - grpcCertificateHash = body.getGrpcCertificateHash().toByteArray(); + var protobufGrpcCert = body.getGrpcCertificateHash(); + grpcCertificateHash = protobufGrpcCert.equals(ByteString.empty()) ? null : protobufGrpcCert.toByteArray(); if (body.hasAdminKey()) { adminKey = Key.fromProtobufKey(body.getAdminKey()); diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java index 7875b2410..19312002f 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java @@ -240,7 +240,6 @@ public AccountId getAccountId() { * @return {@code this} */ public NodeUpdateTransaction setAccountId(AccountId accountId) { - Objects.requireNonNull(accountId); requireNotFrozen(); this.accountId = accountId; return this; @@ -262,7 +261,6 @@ public String getDescription() { */ public NodeUpdateTransaction setDescription(String description) { requireNotFrozen(); - Objects.requireNonNull(description); this.description = description; return this; } @@ -345,7 +343,7 @@ public NodeUpdateTransaction addServiceEndpoint(Endpoint serviceEndpoint) { */ @Nullable public byte[] getGossipCaCertificate() { - return gossipCaCertificate != null ? Arrays.copyOf(gossipCaCertificate, gossipCaCertificate.length) : null; + return gossipCaCertificate; } /** @@ -356,9 +354,8 @@ public byte[] getGossipCaCertificate() { * @return {@code this} */ public NodeUpdateTransaction setGossipCaCertificate(byte[] gossipCaCertificate) { - Objects.requireNonNull(gossipCaCertificate); requireNotFrozen(); - this.gossipCaCertificate = Arrays.copyOf(gossipCaCertificate, gossipCaCertificate.length); + this.gossipCaCertificate = gossipCaCertificate; return this; } @@ -368,7 +365,7 @@ public NodeUpdateTransaction setGossipCaCertificate(byte[] gossipCaCertificate) */ @Nullable public byte[] getGrpcCertificateHash() { - return grpcCertificateHash != null ? Arrays.copyOf(grpcCertificateHash, grpcCertificateHash.length) : null; + return grpcCertificateHash; } /** @@ -379,9 +376,8 @@ public byte[] getGrpcCertificateHash() { * @return {@code this} */ public NodeUpdateTransaction setGrpcCertificateHash(byte[] grpcCertificateHash) { - Objects.requireNonNull(grpcCertificateHash); requireNotFrozen(); - this.grpcCertificateHash = Arrays.copyOf(grpcCertificateHash, grpcCertificateHash.length); + this.grpcCertificateHash = grpcCertificateHash; return this; } @@ -400,7 +396,6 @@ public Key getAdminKey() { * @return {@code this} */ public NodeUpdateTransaction setAdminKey(Key adminKey) { - Objects.requireNonNull(adminKey); requireNotFrozen(); this.adminKey = adminKey; return this; @@ -469,9 +464,13 @@ void initFromTransactionBody() { serviceEndpoints.add(Endpoint.fromProtobuf(serviceEndpoint)); } - gossipCaCertificate = body.getGossipCaCertificate().getValue().toByteArray(); + if (body.hasGossipCaCertificate()) { + gossipCaCertificate = body.getGossipCaCertificate().getValue().toByteArray(); + } - grpcCertificateHash = body.getGrpcCertificateHash().getValue().toByteArray(); + if (body.hasGrpcCertificateHash()) { + grpcCertificateHash = body.getGrpcCertificateHash().getValue().toByteArray(); + } if (body.hasAdminKey()) { adminKey = Key.fromProtobufKey(body.getAdminKey()); diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java index 4760e728e..3c4577b2d 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeCreateTransactionTest.java @@ -122,6 +122,27 @@ void fromScheduledTransaction() { assertThat(tx).isInstanceOf(NodeCreateTransaction.class); } + @Test + void testSerializeDeserialize() throws Exception { + var tx = new NodeCreateTransaction().setDescription(TEST_DESCRIPTION); + var tx2 = new NodeCreateTransaction().setDescription(TEST_DESCRIPTION); + var tx2Bytes = tx2.toBytes(); + NodeCreateTransaction deserializedTx2 = (NodeCreateTransaction) Transaction.fromBytes(tx2Bytes); + assertThat(tx.getGossipCaCertificate()).isEqualTo(deserializedTx2.getGossipCaCertificate()); + assertThat(tx.getGrpcCertificateHash()).isEqualTo(deserializedTx2.getGrpcCertificateHash()); + } + + @Test + void testSetNull() { + new NodeCreateTransaction() + .setDescription(null) + .setAccountId(null) + .setGossipCaCertificate(null) + .setGrpcCertificateHash(null) + .setAdminKey(null); + } + + @Test void constructNodeCreateTransactionFromTransactionBodyProtobuf() { var transactionBodyBuilder = NodeCreateTransactionBody.newBuilder(); diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java index b07b52c90..2d976e435 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java @@ -99,7 +99,6 @@ private NodeUpdateTransaction spawnTestTransaction() { .setTransactionId(TransactionId.withValidStart(AccountId.fromString("0.0.5006"), TEST_VALID_START)) .setNodeId(TEST_NODE_ID) .setAccountId(TEST_ACCOUNT_ID) - .setAccountId(TEST_ACCOUNT_ID) .setDescription(TEST_DESCRIPTION) .setGossipEndpoints(TEST_GOSSIP_ENDPOINTS) .setServiceEndpoints(TEST_SERVICE_ENDPOINTS) @@ -118,6 +117,36 @@ void shouldBytes() throws Exception { assertThat(tx2.toString()).isEqualTo(tx.toString()); } + @Test + void testNullCertificates() throws Exception { + var tx = new NodeUpdateTransaction(); + var tx2Bytes = tx.toBytes(); + NodeUpdateTransaction deserializedTx = (NodeUpdateTransaction) Transaction.fromBytes(tx2Bytes); + assertThat(deserializedTx.getGossipCaCertificate()).isNull(); + assertThat(deserializedTx.getGrpcCertificateHash()).isNull(); + } + + @Test + void testEmptyCertificates() throws Exception { + var tx = new NodeUpdateTransaction() + .setGossipCaCertificate(new byte[]{}) + .setGrpcCertificateHash(new byte[]{}); + var tx2Bytes = tx.toBytes(); + NodeUpdateTransaction deserializedTx = (NodeUpdateTransaction) Transaction.fromBytes(tx2Bytes); + assertThat(deserializedTx.getGossipCaCertificate()).isEqualTo(new byte[]{}); + assertThat(deserializedTx.getGrpcCertificateHash()).isEqualTo(new byte[]{}); + } + + @Test + void testSetNull() { + new NodeUpdateTransaction() + .setDescription(null) + .setAccountId(null) + .setGossipCaCertificate(null) + .setGrpcCertificateHash(null) + .setAdminKey(null); + } + @Test void fromScheduledTransaction() { var transactionBody = SchedulableTransactionBody.newBuilder() From e5abcca0e51d5048e14a7051706ef2961819b569 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Fri, 22 Nov 2024 09:59:51 +0200 Subject: [PATCH 17/18] fix: `NodeUpdateTransaction` sets description as empty string (#2096) Signed-off-by: Ivan Ivanov --- .../java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java | 4 +++- .../com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java index 19312002f..de5a31575 100644 --- a/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java +++ b/sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java @@ -454,7 +454,9 @@ void initFromTransactionBody() { accountId = AccountId.fromProtobuf(body.getAccountId()); } - description = body.getDescription().getValue(); + if (body.hasDescription()) { + description = body.getDescription().getValue(); + } for (var gossipEndpoint : body.getGossipEndpointList()) { gossipEndpoints.add(Endpoint.fromProtobuf(gossipEndpoint)); diff --git a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java index 2d976e435..f56474b57 100644 --- a/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java +++ b/sdk/src/test/java/com/hedera/hashgraph/sdk/NodeUpdateTransactionTest.java @@ -118,12 +118,13 @@ void shouldBytes() throws Exception { } @Test - void testNullCertificates() throws Exception { + void testNullOptionalValues() throws Exception { var tx = new NodeUpdateTransaction(); var tx2Bytes = tx.toBytes(); NodeUpdateTransaction deserializedTx = (NodeUpdateTransaction) Transaction.fromBytes(tx2Bytes); assertThat(deserializedTx.getGossipCaCertificate()).isNull(); assertThat(deserializedTx.getGrpcCertificateHash()).isNull(); + assertThat(deserializedTx.getDescription()).isNull(); } @Test From 9b2617d5f8f55c75ac21713cfdf680334c3c59a5 Mon Sep 17 00:00:00 2001 From: Ivan Ivanov Date: Fri, 22 Nov 2024 11:28:04 +0200 Subject: [PATCH 18/18] release: v2.45.0-beta.1 (#2097) Signed-off-by: Ivan Ivanov --- CHANGELOG.md | 5 +++++ docs/android-app/android-app-quickstart.md | 2 +- docs/java-app/java-app-quickstart.md | 4 ++-- example-android/app/build.gradle.kts | 2 +- examples/build.gradle.kts | 4 ++-- version.txt | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c583bd38..34fcdd034 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/docs/android-app/android-app-quickstart.md b/docs/android-app/android-app-quickstart.md index f267cebc6..e250f5abc 100644 --- a/docs/android-app/android-app-quickstart.md +++ b/docs/android-app/android-app-quickstart.md @@ -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:** diff --git a/docs/java-app/java-app-quickstart.md b/docs/java-app/java-app-quickstart.md index e1a06eb6c..7e1395f1f 100644 --- a/docs/java-app/java-app-quickstart.md +++ b/docs/java-app/java-app-quickstart.md @@ -8,7 +8,7 @@ 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:_ @@ -16,7 +16,7 @@ _Maven:_ com.hedera.hashgraph sdk - 2.44.0 + 2.45.0-beta.1 ``` diff --git a/example-android/app/build.gradle.kts b/example-android/app/build.gradle.kts index a3f456c74..0f6afdd40 100644 --- a/example-android/app/build.gradle.kts +++ b/example-android/app/build.gradle.kts @@ -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") diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 303c7504b..4bb73c207 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -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") } diff --git a/version.txt b/version.txt index 3e197472e..06a5f8e8c 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.44.0 +2.45.0-beta.1