Skip to content

Commit 42955af

Browse files
authored
feat: Delete grpc web proxy method (#2420)
Signed-off-by: Naydenov <nikola.naydenov@limechain.tech>
1 parent d9bffd9 commit 42955af

File tree

5 files changed

+89
-23
lines changed

5 files changed

+89
-23
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ jobs:
179179
uses: hiero-ledger/hiero-solo-action@71219540ac7f578e6ea4fc3c17575c0295e56163 # v0.9
180180
with:
181181
installMirrorNode: true
182-
hieroVersion: v0.63.7
182+
hieroVersion: v0.64.2-rc1
183183

184184
- name: Build SDK
185185
run: ./gradlew assemble
@@ -237,7 +237,7 @@ jobs:
237237
uses: hiero-ledger/hiero-solo-action@71219540ac7f578e6ea4fc3c17575c0295e56163 # v0.9
238238
with:
239239
installMirrorNode: true
240-
hieroVersion: v0.63.7
240+
hieroVersion: v0.64.2-rc1
241241

242242
- name: Build SDK
243243
run: ./gradlew assemble

examples/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ abstract class RunAllExample : DefaultTask() {
7878
it != "SolidityPrecompileExample"
7979
} // disabled - cannot run on solo action
8080
.filter { it != "ZeroTokenOperationsExample" && it != "ScheduleExample" }
81+
.filter {
82+
it != "MirrorNodeContractQueriesExample"
83+
} // disabled due to consensus node issue
8184
.toList()
8285

8386
exampleClasses.forEach { className ->

sdk/src/main/java/com/hedera/hashgraph/sdk/NodeUpdateTransaction.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,4 +548,18 @@ public NodeUpdateTransaction freezeWith(@Nullable Client client) {
548548
}
549549
return super.freezeWith(client);
550550
}
551+
552+
/**
553+
* Delete the gRPC web proxy endpoint.
554+
* <p>
555+
* This method clears the gRPC web proxy endpoint by setting it to an empty
556+
* Endpoint, which will effectively delete it in the mirror node.
557+
*
558+
* @return {@code this}
559+
*/
560+
public NodeUpdateTransaction deleteGrpcWebProxyEndpoint() {
561+
requireNotFrozen();
562+
this.grpcWebProxyEndpoint = new Endpoint();
563+
return this;
564+
}
551565
}

sdk/src/testIntegration/java/com/hedera/hashgraph/sdk/test/integration/NodeCreateTransactionIntegrationTest.java

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
import com.hedera.hashgraph.sdk.Client;
88
import com.hedera.hashgraph.sdk.Endpoint;
99
import com.hedera.hashgraph.sdk.NodeCreateTransaction;
10-
import com.hedera.hashgraph.sdk.NodeUpdateTransaction;
1110
import com.hedera.hashgraph.sdk.PrivateKey;
1211
import com.hedera.hashgraph.sdk.PrivateKeyECDSA;
1312
import java.util.HashMap;
1413
import java.util.List;
1514
import org.bouncycastle.util.encoders.Hex;
16-
import org.junit.jupiter.api.Disabled;
1715
import org.junit.jupiter.api.DisplayName;
1816
import org.junit.jupiter.api.Test;
1917

@@ -22,7 +20,6 @@ class NodeCreateTransactionIntegrationTest {
2220
"3082052830820310a003020102020101300d06092a864886f70d01010c05003010310e300c060355040313056e6f6465333024170d3234313030383134333233395a181332313234313030383134333233392e3337395a3010310e300c060355040313056e6f64653330820222300d06092a864886f70d01010105000382020f003082020a0282020100af111cff0c4ad8125d2f4b8691ce87332fecc867f7a94ddc0f3f96514cc4224d44af516394f7384c1ef0a515d29aa6116b65bc7e4d7e2d848cf79fbfffedae3a6583b3957a438bdd780c4981b800676ea509bc8c619ae04093b5fc642c4484152f0e8bcaabf19eae025b630028d183a2f47caf6d9f1075efb30a4248679d871beef1b7e9115382270cbdb68682fae4b1fd592cadb414d918c0a8c23795c7c5a91e22b3e90c410825a2bc1a840efc5bf9976a7f474c7ed7dc047e4ddd2db631b68bb4475f173baa3edc234c4bed79c83e2f826f79e07d0aade2d984da447a8514135bfa4145274a7f62959a23c4f0fae5adc6855974e7c04164951d052beb5d45cb1f3cdfd005da894dea9151cb62ba43f4731c6bb0c83e10fd842763ba6844ef499f71bc67fa13e4917fb39f2ad18112170d31cdcb3c61c9e3253accf703dbd8427fdcb87ece78b787b6cfdc091e8fedea8ad95dc64074e1fc6d0e42ea2337e18a5e54e4aaab3791a98dfcef282e2ae1caec9cf986fabe8f36e6a21c8711647177e492d264415e765a86c58599cd97b103cb4f6a01d2edd06e3b60470cf64daca7aecf831197b466cae04baeeac19840a05394bef628aed04b611cfa13677724b08ddfd662b02fd0ef0af17eb7f4fb8c1c17fbe9324f6dc7bcc02449622636cc45ec04909b3120ab4df4726b21bf79e955fe8f832699d2196dcd7a58bfeafb170203010001a38186308183300f0603551d130101ff04053003020100300e0603551d0f0101ff0404030204b030200603551d250101ff0416301406082b0601050507030106082b06010505070302301d0603551d0e04160414643118e05209035edd83d44a0c368de2fb2fe4c0301f0603551d23041830168014643118e05209035edd83d44a0c368de2fb2fe4c0300d06092a864886f70d01010c05000382020100ad41c32bb52650eb4b76fce439c9404e84e4538a94916b3dc7983e8b5c58890556e7384601ca7440dde68233bb07b97bf879b64487b447df510897d2a0a4e789c409a9b237a6ad240ad5464f2ce80c58ddc4d07a29a74eb25e1223db6c00e334d7a27d32bfa6183a82f5e35bccf497c2445a526eabb0c068aba9b94cc092ea4756b0dcfb574f6179f0089e52b174ccdbd04123eeb6d70daeabd8513fcba6be0bc2b45ca9a69802dae11cc4d9ff6053b3a87fd8b0c6bf72fffc3b81167f73cca2b3fd656c5d353c8defca8a76e2ad535f984870a590af4e28fed5c5a125bf360747c5e7742e7813d1bd39b5498c8eb6ba72f267eda034314fdbc596f6b967a0ef8be5231d364e634444c84e64bd7919425171016fcd9bb05f01c58a303dee28241f6e860fc3aac3d92aad7dac2801ce79a3b41a0e1f1509fc0d86e96d94edb18616c000152490f64561713102128990fedd3a5fa642f2ff22dc11bc4dc5b209986a0c3e4eb2bdfdd40e9fdf246f702441cac058dd8d0d51eb0796e2bea2ce1b37b2a2f468505e1f8980a9f66d719df034a6fbbd2f9585991d259678fb9a4aebdc465d22c240351ed44abffbdd11b79a706fdf7c40158d3da87f68d7bd557191a8016b5b899c07bf1b87590feb4fa4203feea9a2a7a73ec224813a12b7a21e5dc93fcde4f0a7620f570d31fe27e9b8d65b74db7dc18a5e51adc42d7805d4661938";
2321

2422
@Test
25-
@Disabled("The test has to be disabled so it doesn't fail calls to local-node")
2623
@DisplayName("Can create new network node")
2724
void canCreateNewNetworkNode() throws Exception {
2825
// Set the network
@@ -43,13 +40,11 @@ void canCreateNewNetworkNode() throws Exception {
4340
String description = "test";
4441

4542
// Endpoint address can be any IPV4 address
46-
var endpoint = new Endpoint().setDomainName("tests.com").setPort(1234);
47-
var endpoint2 = new Endpoint().setDomainName("test.com").setPort(123);
43+
var endpoint = new Endpoint().setDomainName("tset.com").setPort(123);
44+
var endpoint2 = new Endpoint().setDomainName("test.com").setPort(1234);
4845

4946
// Set up grpcWebProxyEndpoint address
50-
var grpcWebProxyEndpoint = new Endpoint()
51-
.setAddress(new byte[] {0x00, 0x01, 0x02, 0x05})
52-
.setPort(12345);
47+
var grpcWebProxyEndpoint = new Endpoint().setDomainName("test.com").setPort(12345);
5348

5449
// Convert hex string to byte array
5550
var validGossipCert = Hex.decode(validGossipCertDER.getBytes());
@@ -70,19 +65,6 @@ void canCreateNewNetworkNode() throws Exception {
7065
.sign(adminKey)
7166
.execute(client)
7267
.getReceipt(client);
73-
74-
var grpcWebProxyEndpointUpdated = new Endpoint()
75-
.setAddress(new byte[] {0x00, 0x01, 0x02, 0x06})
76-
.setPort(123456);
77-
78-
new NodeUpdateTransaction()
79-
.setAccountId(accountID)
80-
.setDeclineReward(false)
81-
.setGrpcWebProxyEndpoint(grpcWebProxyEndpointUpdated)
82-
.freezeWith(client)
83-
.sign(adminKey)
84-
.execute(client)
85-
.getReceipt(client);
8668
}
8769
}
8870
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package com.hedera.hashgraph.sdk.test.integration;
3+
4+
import com.hedera.hashgraph.sdk.AccountId;
5+
import com.hedera.hashgraph.sdk.Client;
6+
import com.hedera.hashgraph.sdk.Endpoint;
7+
import com.hedera.hashgraph.sdk.NodeUpdateTransaction;
8+
import com.hedera.hashgraph.sdk.PrivateKey;
9+
import java.util.HashMap;
10+
import java.util.List;
11+
import org.junit.jupiter.api.DisplayName;
12+
import org.junit.jupiter.api.Test;
13+
14+
class NodeUpdateTransactionIntegrationTest {
15+
16+
@Test
17+
@DisplayName("Can execute NodeUpdateTransaction")
18+
void canExecuteNodeUpdateTransaction() throws Exception {
19+
// Set the network
20+
var network = new HashMap<String, AccountId>();
21+
network.put("localhost:50211", new AccountId(0, 0, 3));
22+
23+
try (var client = Client.forNetwork(network).setMirrorNetwork(List.of("localhost:5600"))) {
24+
25+
// Set the operator to be account 0.0.2
26+
var originalOperatorKey = PrivateKey.fromString(
27+
"302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137");
28+
client.setOperator(new AccountId(0, 0, 2), originalOperatorKey);
29+
30+
// Set up grpcWebProxyEndpoint address
31+
var grpcWebProxyEndpoint =
32+
new Endpoint().setDomainName("testWebUpdated.com").setPort(123456);
33+
34+
var response = new NodeUpdateTransaction()
35+
.setNodeId(0)
36+
.setDescription("testUpdated")
37+
.setDeclineReward(true)
38+
.setGrpcWebProxyEndpoint(grpcWebProxyEndpoint)
39+
.execute(client);
40+
41+
response.getReceipt(client);
42+
}
43+
}
44+
45+
@Test
46+
@DisplayName("Can delete gRPC web proxy endpoint")
47+
void canDeleteGrpcWebProxyEndpoint() throws Exception {
48+
// Set the network
49+
var network = new HashMap<String, AccountId>();
50+
network.put("localhost:50211", new AccountId(0, 0, 3));
51+
52+
try (var client = Client.forNetwork(network).setMirrorNetwork(List.of("localhost:5600"))) {
53+
54+
// Set the operator to be account 0.0.2
55+
var originalOperatorKey = PrivateKey.fromString(
56+
"302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137");
57+
client.setOperator(new AccountId(0, 0, 2), originalOperatorKey);
58+
59+
var response = new NodeUpdateTransaction()
60+
.setNodeId(0)
61+
.deleteGrpcWebProxyEndpoint()
62+
.execute(client);
63+
64+
response.getReceipt(client);
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)