use of com.hedera.hashgraph.sdk.TopicInfo in project hedera-sdk-java by hashgraph.
the class TopicWithAdminKeyExample method updateTopicAdminKeyAndMemo.
private void updateTopicAdminKeyAndMemo() throws TimeoutException, PrecheckStatusException, ReceiptStatusException {
// Generate the new keys that are part of the adminKey's thresholdKey.
// 4 ED25519 keys part of a 3-of-4 threshold key.
PrivateKey[] newAdminKeys = new PrivateKey[4];
J8Arrays.setAll(newAdminKeys, i -> PrivateKey.generate());
KeyList thresholdKey = KeyList.withThreshold(3);
Collections.addAll(thresholdKey, newAdminKeys);
Transaction<?> transaction = new TopicUpdateTransaction().setTopicId(topicId).setTopicMemo("updated demo topic").setAdminKey(thresholdKey).freezeWith(hapiClient);
// Sign with the initial adminKey. 2 of the 3 keys already part of the topic's adminKey.
J8Arrays.stream(initialAdminKeys, 0, 2).forEach(k -> {
System.out.println("Signing ConsensusTopicUpdateTransaction with initial admin key " + k);
transaction.sign(k);
});
// Sign with the new adminKey. 3 of 4 keys already part of the topic's adminKey.
J8Arrays.stream(newAdminKeys, 0, 3).forEach(k -> {
System.out.println("Signing ConsensusTopicUpdateTransaction with new admin key " + k);
transaction.sign(k);
});
TransactionResponse transactionResponse = transaction.execute(hapiClient);
// Retrieve results post-consensus.
transactionResponse.getReceipt(hapiClient);
System.out.println("Updated topic " + topicId + " with 3-of-4 threshold key as adminKey");
TopicInfo topicInfo = new TopicInfoQuery().setTopicId(topicId).execute(hapiClient);
System.out.println(topicInfo);
}
use of com.hedera.hashgraph.sdk.TopicInfo in project hedera-mirror-node by hashgraph.
the class TopicFeature method verifyTopicOnNetwork.
@Then("the network should successfully observe the topic")
public void verifyTopicOnNetwork() {
TopicInfo topicInfo = topicClient.getTopicInfo(consensusTopicId);
assertNotNull(topicInfo, "topicInfo is null");
assertNotEquals("", topicInfo.topicMemo, "topicMemo is not empty");
assertThat(topicInfo.sequenceNumber).isGreaterThanOrEqualTo(messageSubscribeCount);
}
Aggregations