Skip to content

Commit 90a86c6

Browse files
committed
Merge branch 'main' into fix/file-service-admin-keys-handling
Signed-off-by: ParasSalonia <parassalonia22@gmail.com>
2 parents 5b68547 + 6e2943a commit 90a86c6

File tree

106 files changed

+10122
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+10122
-210
lines changed

.github/workflows/zxc-build-library.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,10 @@ jobs:
182182
id: solo
183183
uses: hiero-ledger/hiero-solo-action@4d42a74e8e644a2753f3bb7a2afa429305375b14 # v0.17.0
184184
with:
185+
soloVersion: v0.64.1
185186
installMirrorNode: true
186-
mirrorNodeVersion: v0.142.0
187-
hieroVersion: v0.69.1
187+
mirrorNodeVersion: v0.151.0
188+
hieroVersion: v0.72.0
188189
dualMode: true
189190

190191
- name: Start CTest suite (Debug)

HieroApi.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
set(HAPI_VERSION_TAG "v0.69.1" CACHE STRING "Use the configured version tag for the Hiero API protobufs")
2-
set(HAPI_COMMIT_HASH "83fa1eb1446524aa695fa2c0d817361805afb979" CACHE STRING "Use the configured commit hash for the Hiero API protobufs (overrides version tag if provided)")
1+
set(HAPI_VERSION_TAG "v0.72.0" CACHE STRING "Use the configured version tag for the Hiero API protobufs")
2+
set(HAPI_COMMIT_HASH "" CACHE STRING "Use the configured commit hash for the Hiero API protobufs (overrides version tag if provided)")
33

44
if (HAPI_VERSION_TAG STREQUAL "")
5-
set(HAPI_VERSION_TAG "v0.69.1")
5+
set(HAPI_VERSION_TAG "v0.72.0")
66
endif ()
77

88
# Use commit hash if provided, otherwise use version tag

docs/maintainers/guidelines-advanced-issues.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ These issues often involve shaping how the SDK evolves over time.
4040

4141
Contributors must have completed at least **3 Intermediate Issues** in this repository before being assigned an Advanced issue.
4242

43+
*Note: Contributors who have already completed at least one Advanced issue bypass this prerequisite and can always take on more Advanced issues.*
44+
4345
This requirement is enforced automatically by the `/assign` bot.
4446

4547
---

proto/CMakeLists.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Begin Protobuf Definitions
22
set(PROTO_FILES
3-
block/stream/chain_of_trust_proof.proto
43
transaction_list.proto
54

65
mirror/consensus_service.proto
@@ -58,15 +57,19 @@ set(PROTO_FILES
5857
services/get_by_key.proto
5958
services/get_by_solidity_id.proto
6059
services/hook_dispatch.proto
60+
services/hook_store.proto
6161
services/hook_types.proto
62-
services/lambda_sstore.proto
6362
services/network_get_execution_time.proto
6463
services/network_get_version_info.proto
6564
services/network_service.proto
6665
services/node_create.proto
6766
services/node_delete.proto
6867
services/node_stake_update.proto
6968
services/node_update.proto
69+
services/registered_node_create.proto
70+
services/registered_node_delete.proto
71+
services/registered_node_update.proto
72+
services/registered_service_endpoint.proto
7073
services/query.proto
7174
services/query_header.proto
7275
services/response.proto
@@ -127,6 +130,8 @@ set(PROTO_FILES
127130
services/auxiliary/history/history_proof_signature.proto
128131
services/auxiliary/history/history_proof_key_publication.proto
129132
services/auxiliary/history/history_proof_vote.proto
133+
services/auxiliary/tss/ledger_id_publication.proto
134+
services/auxiliary/tss/tss_encryption_key.proto
130135
services/auxiliary/tss/tss_message.proto
131136
services/auxiliary/tss/tss_vote.proto
132137

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
#include "AccountCreateTransaction.h"
3+
#include "AccountId.h"
4+
#include "AccountUpdateTransaction.h"
5+
#include "Client.h"
6+
#include "ContractCreateTransaction.h"
7+
#include "ContractId.h"
8+
#include "ED25519PrivateKey.h"
9+
#include "Hbar.h"
10+
#include "PublicKey.h"
11+
#include "TransactionReceipt.h"
12+
#include "TransactionResponse.h"
13+
#include "hooks/EvmHook.h"
14+
#include "hooks/EvmHookSpec.h"
15+
#include "hooks/HookCreationDetails.h"
16+
#include "hooks/HookExtensionPoint.h"
17+
#include "impl/HexConverter.h"
18+
#include "impl/Utilities.h"
19+
20+
#include <dotenv.h>
21+
#include <filesystem>
22+
#include <fstream>
23+
#include <iostream>
24+
25+
using namespace Hiero;
26+
27+
static const std::string kContractBytecodeHex =
28+
"608060405234801561001057600080fd5b50600436106100365760003560e01c8063c29855781461003b578063f2fde38b14610059575b60"
29+
"0080fd5b610043610075565b60405161005091906100a1565b60405180910390f35b610073600480360381019061006e91906100ed565b61"
30+
"007b565b005b60005481565b8073ffffffffffffffffffffffffffffffffffffffff1660008054906101000a900473ffffffffffffffffff"
31+
"ffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722"
32+
"a3daafe3b4186f6b6457e060405160405180910390a3806000806101000a81548173ffffffffffffffffffffffffffffffffffffffff0219"
33+
"16908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6000819050919050565b61009b81610088565b82525050"
34+
"565b60006020820190506100b66000830184610092565b92915050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffff"
35+
"ff82169050919050565b60006100e7826100bc565b9050919050565b6100f7816100dc565b811461010257600080fd5b50565b6000813590"
36+
"50610114816100ee565b92915050565b6000602082840312156101305761012f6100bc565b5b600061013e84828501610105565b91505092"
37+
"91505056fea2646970667358221220";
38+
39+
ContractId createHookContract(Client& client, const std::shared_ptr<PrivateKey>& operatorKey)
40+
{
41+
std::cout << "Creating hook contract..." << std::endl;
42+
const TransactionReceipt txReceipt = ContractCreateTransaction()
43+
.setAdminKey(operatorKey->getPublicKey())
44+
.setGas(500000ULL)
45+
.setBytecode(internal::HexConverter::hexToBytes(kContractBytecodeHex))
46+
.execute(client)
47+
.getReceipt(client);
48+
49+
if (!txReceipt.mContractId.has_value())
50+
{
51+
throw std::runtime_error("Failed to create hook contract!");
52+
}
53+
54+
std::cout << "Hook contract created with ID: " << txReceipt.mContractId.value().toString() << std::endl;
55+
return txReceipt.mContractId.value();
56+
}
57+
58+
std::pair<AccountId, std::shared_ptr<PrivateKey>> createAccountWithHook(Client& client,
59+
const ContractId& contractId,
60+
const std::shared_ptr<PublicKey>& adminKey)
61+
{
62+
const std::shared_ptr<PrivateKey> accountKey = ED25519PrivateKey::generatePrivateKey();
63+
EvmHookSpec evmHookSpec;
64+
evmHookSpec.setContractId(contractId);
65+
EvmHook evmHook;
66+
evmHook.setEvmHookSpec(evmHookSpec);
67+
HookCreationDetails hookWithId1002;
68+
hookWithId1002.setExtensionPoint(HookExtensionPoint::ACCOUNT_ALLOWANCE_HOOK);
69+
hookWithId1002.setHookId(1002LL);
70+
hookWithId1002.setEvmHook(evmHook);
71+
hookWithId1002.setAdminKey(adminKey);
72+
const TransactionReceipt txReceipt = AccountCreateTransaction()
73+
.setKeyWithoutAlias(accountKey->getPublicKey())
74+
.setInitialBalance(Hbar(1ULL))
75+
.addHook(hookWithId1002)
76+
.execute(client)
77+
.getReceipt(client);
78+
if (!txReceipt.mAccountId.has_value())
79+
{
80+
throw std::runtime_error("Failed to create account with hook!");
81+
}
82+
std::cout << "account id = " << txReceipt.mAccountId.value().toString() << std::endl;
83+
std::cout << "Successfully created account with hook!" << std::endl;
84+
return { txReceipt.mAccountId.value(), accountKey };
85+
}
86+
87+
void addHooksToAccount(Client& client,
88+
const AccountId& accountId,
89+
const std::shared_ptr<PrivateKey>& accountKey,
90+
const EvmHookSpec& evmHookSpec,
91+
const std::shared_ptr<PublicKey>& adminKey)
92+
{
93+
std::cout << "\n=== Adding Hooks to Existing Account ===" << std::endl;
94+
EvmHook hook1;
95+
hook1.setEvmHookSpec(evmHookSpec);
96+
HookCreationDetails hookWithId1;
97+
hookWithId1.setExtensionPoint(HookExtensionPoint::ACCOUNT_ALLOWANCE_HOOK);
98+
hookWithId1.setHookId(1LL);
99+
hookWithId1.setEvmHook(hook1);
100+
hookWithId1.setAdminKey(adminKey);
101+
EvmHook hook2;
102+
hook2.setEvmHookSpec(evmHookSpec);
103+
HookCreationDetails hookWithId2;
104+
hookWithId2.setExtensionPoint(HookExtensionPoint::ACCOUNT_ALLOWANCE_HOOK);
105+
hookWithId2.setHookId(2LL);
106+
hookWithId2.setEvmHook(hook2);
107+
hookWithId2.setAdminKey(adminKey);
108+
try
109+
{
110+
AccountUpdateTransaction()
111+
.setAccountId(accountId)
112+
.addHookToCreate(hookWithId1)
113+
.addHookToCreate(hookWithId2)
114+
.freezeWith(&client)
115+
.sign(accountKey)
116+
.execute(client)
117+
.getReceipt(client);
118+
std::cout << "Successfully added hooks to account!" << std::endl;
119+
}
120+
catch (const std::exception& error)
121+
{
122+
std::cerr << "Failed to execute hook transaction: " << error.what() << std::endl;
123+
}
124+
}
125+
126+
void deleteHooksFromAccount(Client& client, const AccountId& accountId, const std::shared_ptr<PrivateKey>& accountKey)
127+
{
128+
std::cout << "\n=== Deleting Hooks from Account ===" << std::endl;
129+
try
130+
{
131+
AccountUpdateTransaction()
132+
.setAccountId(accountId)
133+
.addHookToDelete(1LL)
134+
.addHookToDelete(2LL)
135+
.freezeWith(&client)
136+
.sign(accountKey)
137+
.execute(client)
138+
.getReceipt(client);
139+
std::cout << "Successfully deleted hooks (IDs: 1, 2)" << std::endl;
140+
}
141+
catch (const std::exception& error)
142+
{
143+
std::cerr << "Failed to execute hook deletion: " << error.what() << std::endl;
144+
}
145+
}
146+
147+
void run(Client& client, const std::shared_ptr<PrivateKey>& operatorKey)
148+
{
149+
std::cout << "Account Hooks Example Start!" << std::endl;
150+
const ContractId contractId = createHookContract(client, operatorKey);
151+
std::cout << "\n=== Creating Account with Hooks ===" << std::endl;
152+
const std::shared_ptr<PublicKey> adminKey = client.getOperatorPublicKey();
153+
const auto [accountId, accountKey] = createAccountWithHook(client, contractId, adminKey);
154+
EvmHookSpec evmHookSpec;
155+
evmHookSpec.setContractId(contractId);
156+
addHooksToAccount(client, accountId, accountKey, evmHookSpec, adminKey);
157+
deleteHooksFromAccount(client, accountId, accountKey);
158+
std::cout << "Account Hooks Example Complete!" << std::endl;
159+
}
160+
161+
int main(int argc, char** argv)
162+
{
163+
dotenv::init();
164+
if (std::getenv("OPERATOR_ID") == nullptr || std::getenv("OPERATOR_KEY") == nullptr ||
165+
std::getenv("NETWORK_NAME") == nullptr)
166+
{
167+
std::cerr << "Environment variables OPERATOR_ID, NETWORK_NAME, and OPERATOR_KEY are required." << std::endl;
168+
return 1;
169+
}
170+
Client client = Client::forName(std::getenv("NETWORK_NAME"));
171+
client.setOperator(AccountId::fromString(std::getenv("OPERATOR_ID")),
172+
ED25519PrivateKey::fromString(std::getenv("OPERATOR_KEY")));
173+
try
174+
{
175+
run(client, ED25519PrivateKey::fromString(std::getenv("OPERATOR_KEY")));
176+
}
177+
catch (const std::exception& error)
178+
{
179+
std::cerr << "Error occurred: " << error.what() << std::endl;
180+
return 1;
181+
}
182+
client.close();
183+
return 0;
184+
}

0 commit comments

Comments
 (0)