Skip to content

Commit e8263fb

Browse files
authored
Update protos to 0.61.0 (#451)
* chore: update protobufs to v0.61.0 Signed-off-by: Ricky Saechao <ricky@launchbadge.com> * chore: update README.md docs for testing Signed-off-by: Ricky Saechao <ricky@launchbadge.com> --------- Signed-off-by: Ricky Saechao <ricky@launchbadge.com>
1 parent db7e667 commit e8263fb

File tree

329 files changed

+3570
-12179
lines changed

Some content is hidden

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

329 files changed

+3570
-12179
lines changed

Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ let package = Package(
115115
.product(name: "GRPC", package: "grpc-swift"),
116116
],
117117
exclude: [
118-
"Protos"
118+
"Protos",
119+
"update_protos.py",
119120
]
120121
),
121122
// weird name, but whatever, internal targets

README.md

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Hiero Swift SDK
22

3-
The SDK for interacting with a Hiero based netwrok.
3+
The SDK for interacting with a Hiero based network.
44

5-
<sub>Maintained with ❤️ by <a href="https://launchbadge.com" target="_blank">LaunchBadge</a>, <a href="https://www.hashgraph.com/" target="_blank">Hashgraph</a>, and the Hedera community</sub>
5+
<sub>Maintained with ❤️ by <a href="https://launchbadge.com" target="_blank">LaunchBadge</a>, <a href="https://www.hashgraph.com/" target="_blank">Hashgraph</a>, and the Hiero community</sub>
66

77
## Usage
88

@@ -17,7 +17,7 @@ The SDK for interacting with a Hiero based netwrok.
1717
```swift
1818
// Package.swift
1919
dependencies: [
20-
.package(url: "https://github.com/hiero-project/hiero-sdk-swift.git", from: "1.0.0")
20+
.package(url: "https://github.com/hiero-project/hiero-sdk-swift.git", from: "0.36.0")
2121
]
2222
```
2323

@@ -40,44 +40,49 @@ let ab = try await AccountBalanceQuery()
4040
print("balance = \(ab.balance)")
4141
```
4242

43-
See [examples](./Examples) for more usage.
44-
45-
## Development (HederaProtobufs)
43+
## Development (HieroProtobufs)
4644

47-
HederaProtobufs is entirely generated. The protobufs repo will be migrated to Hiero [in near future](https://github.com/LFDT-Hiero/hiero/blob/main/transition.md).
45+
HieroProtobufs are entirely generated.
4846

4947
### Required Tooling
5048

5149
protoc
5250
protoc-gen-swift (from https://github.com/apple/swift-protobuf)
5351
protoc-gen-grpc-swift (from https://github.com/grpc/grpc-swift)
5452
task (from https://github.com/go-task/task)
53+
openSSL 3.4 (from https://openssl-library.org/source/)
54+
55+
### Fetch Submodule and Generate Swift Protobufs (HieroProtobufs)
5556

56-
### Fetch Submodule (Hedera-Protobufs)
57+
Update [\protobufs](https://github.com/hiero-ledger/hiero-consensus-node.git) submodule to latest changes.
5758

58-
Update [\protobuf](https://github.com/hashgraph/hedera-protobufs) submodule to latest changes.
5959
```bash
60-
## Fetch the latest version of the services submodule
61-
## Note: Append "proto=<version>" to fetch a specific version
60+
# Fetch the latest version of the services submodule
61+
# and generate swift code for Hiero protobufs and gRPC.
62+
#
63+
# Note: Append "proto=vX.Y.Z" to fetch a specific version
6264
task submodule:fetch
6365

64-
## Update the submodule to the latest version
65-
task submodule:install
66-
66+
# e.g. move submodule to v0.61.0 tag
67+
task submodule:fetch proto=v0.61.0
6768
```
6869

69-
### Generate services
70+
### Examples
71+
See [examples](./Examples) for more usage.
72+
7073
```bash
71-
# cwd: `$REPO`
72-
protoc --swift_opt=Visibility=Public --swift_opt=FileNaming=PathToUnderscores --swift_out=./Sources/HieroProtobufs/Services --proto_path=./Sources/HieroProtobufs/Protos/services Sources/HieroProtobufs/Protos/services/*.proto
74+
# Run an example
75+
$ task example name=<example>
76+
77+
# e.g CreateAccount
78+
$ task example name=CreateAccount
7379

74-
# generate GRPC (if needed)
75-
protoc --grpc-swift_opt=Visibility=Public,Server=false --grpc-swift_out=./Sources/HieroProtobufs/Services --proto_path=./Sources/HieroProtobufs/Protos/services Sources/HieroProtobufs/Protos/services/*.proto
7680
```
7781

78-
### Integration Tests
82+
### Testing
83+
See [HieroTests](./Tests/HieroTests) and [HieroE2ETests](./Tests/HieroE2ETests)
7984

80-
Before running the integration tests, an operator key, operator account id, and a network name must be set in an `.env` file.
85+
Before running the integration tests (e2e)– an operator key, operator account id, and a network name must be set in an `.env` file. Unit tests do not require `.env` to be executed.
8186

8287
```bash
8388
# Account that will pay query and transaction fees
@@ -87,18 +92,28 @@ TEST_OPERATOR_KEY=
8792
# Network names: `"localhost"`, `"testnet"`, `"previewnet"`, `"mainnet"`
8893
TEST_NETWORK_NAME=
8994
```
95+
9096
```bash
91-
# Run tests
92-
$ swift test
97+
# Run all unit and e2e tests
98+
$ swift test
99+
100+
# Run specific tests
101+
$ swift test --filter <subclass>/<testMethod>
102+
103+
# e.g. AccountCreateTransactionTests/testSerialize (unit test)
104+
$ swift test --filter AccountCreateTransactionTests/testSerialize
105+
106+
# e.g. AccountCreate/testInitialBalanceAndKey (e2e test)
107+
$ swift test --filter AccountCreate/testInitialBalanceAndKey
93108
```
94109

95110
The networks testnet, previewnet, and mainnet are the related and publicly available [Hedera networks](https://docs.hedera.com/hedera/networks).
96111

112+
97113
### Local Environment Testing
98114

99-
You can run tests through your localhost using the `hedera-local-node` service.
100-
For instructions on how to set up and run local node, follow the steps in the [git repository](https://github.com/hashgraph/hedera-local-node).
101-
The repo will be migrated to Hiero [in near future](https://github.com/LFDT-Hiero/hiero/blob/main/transition.md).
115+
You can run tests through your localhost using the `hiero-local-node` service.
116+
For instructions on how to set up and run local node, follow the steps in the [git repository](https://github.com/hiero-ledger/hiero-local-node).
102117
Once the local node is running in Docker, the appropriate `.env` values must be set:
103118

104119
```bash

Sources/Hiero/AnyTransaction.swift

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ internal enum ServicesTransactionDataList {
7676
case historyProofKeyPublication(
7777
[Com_Hedera_Hapi_Services_Auxiliary_History_HistoryProofKeyPublicationTransactionBody])
7878
case historyProofVote([Com_Hedera_Hapi_Services_Auxiliary_History_HistoryProofVoteTransactionBody])
79+
case hintsPreprocessingVote([Com_Hedera_Hapi_Services_Auxiliary_Hints_HintsPreprocessingVoteTransactionBody])
80+
case hintsKeyPublication([Com_Hedera_Hapi_Services_Auxiliary_Hints_HintsKeyPublicationTransactionBody])
81+
case hintsPartialSignature([Com_Hedera_Hapi_Services_Auxiliary_Hints_HintsPartialSignatureTransactionBody])
82+
case crsPublication([Com_Hedera_Hapi_Services_Auxiliary_Hints_CrsPublicationTransactionBody])
83+
case atomicBatch([Proto_AtomicBatchTransactionBody])
7984

8085
internal mutating func append(_ transaction: Proto_TransactionBody.OneOf_Data) throws {
8186
switch (self, transaction) {
@@ -275,6 +280,42 @@ internal enum ServicesTransactionDataList {
275280
array.append(data)
276281
self = .tokenCancelAirdrop(array)
277282

283+
case (.stateSignatureTransaction(var array), .stateSignatureTransaction(let data)):
284+
array.append(data)
285+
self = .stateSignatureTransaction(array)
286+
287+
case (.historyProofSignature(var array), .historyProofSignature(let data)):
288+
array.append(data)
289+
self = .historyProofSignature(array)
290+
291+
case (.historyProofKeyPublication(var array), .historyProofKeyPublication(let data)):
292+
array.append(data)
293+
self = .historyProofKeyPublication(array)
294+
295+
case (.historyProofVote(var array), .historyProofVote(let data)):
296+
array.append(data)
297+
self = .historyProofVote(array)
298+
299+
case (.hintsPreprocessingVote(var array), .hintsPreprocessingVote(let data)):
300+
array.append(data)
301+
self = .hintsPreprocessingVote(array)
302+
303+
case (.hintsKeyPublication(var array), .hintsKeyPublication(let data)):
304+
array.append(data)
305+
self = .hintsKeyPublication(array)
306+
307+
case (.hintsPartialSignature(var array), .hintsPartialSignature(let data)):
308+
array.append(data)
309+
self = .hintsPartialSignature(array)
310+
311+
case (.crsPublication(var array), .crsPublication(let data)):
312+
array.append(data)
313+
self = .crsPublication(array)
314+
315+
case (.atomicBatch(var array), .atomicBatch(let data)):
316+
array.append(data)
317+
self = .atomicBatch(array)
318+
278319
default:
279320
throw HError.fromProtobuf("mismatched transaction types")
280321
}
@@ -348,11 +389,22 @@ extension ServicesTransactionDataList: TryFromProtobuf {
348389
case .tokenClaimAirdrop(let data): value = .tokenClaimAirdrop([data])
349390
case .stateSignatureTransaction:
350391
throw HError.fromProtobuf("Unsupported transaction `StateSignatureTransaction`")
392+
case .hintsPreprocessingVote:
393+
throw HError.fromProtobuf("Unsupported transaction `HintsPreprocessingVoteTransaction`")
394+
case .hintsKeyPublication:
395+
throw HError.fromProtobuf("Unsupported transaction `HintsKeyPublicationTransaction`")
396+
case .hintsPartialSignature:
397+
throw HError.fromProtobuf("Unsupported transaction `HintsPartialSignatureTransaction`")
351398
case .historyProofSignature:
352-
throw HError.fromProtobuf("Unsupported transaction `HistoryAssemblySignatureTransaction`")
399+
throw HError.fromProtobuf("Unsupported transaction `HistoryProofSignatureTransaction`")
353400
case .historyProofKeyPublication:
354401
throw HError.fromProtobuf("Unsupported transaction `HistoryProofKeyPublicationTransaction`")
355-
case .historyProofVote: throw HError.fromProtobuf("Unsupported transaction `HistoryProofVoteTransaction`")
402+
case .historyProofVote:
403+
throw HError.fromProtobuf("Unsupported transaction `HistoryProofVoteTransaction`")
404+
case .crsPublication:
405+
throw HError.fromProtobuf("Unsupported transaction `CrsPublicationTransaction`")
406+
case .atomicBatch:
407+
throw HError.fromProtobuf("Unsupported transaction `AtomicBatchTransaction`")
356408
}
357409

358410
for transaction in iter {

Sources/Hiero/FeeSchedule/RequestType.swift

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,15 @@ public enum RequestType {
254254
/// State signature transaction
255255
case stateSignatureTransaction
256256

257+
/// Hints preprocessing vote transaction
258+
case hintsPreprocessingVote
259+
260+
/// Hints key publication transaction
261+
case hintsKeyPublication
262+
263+
/// Hints partial signature transaction
264+
case hintsPartialSignature
265+
257266
/// History assembly signature
258267
case historyAssemblySignature
259268

@@ -263,6 +272,12 @@ public enum RequestType {
263272
/// History proof vote
264273
case historyProofVote
265274

275+
/// CRS publication transaction
276+
case crsPublication
277+
278+
/// Atomic batch transaction
279+
case atomicBatch
280+
266281
// swiftlint:disable:next function_body_length
267282
internal init?(protobuf proto: Proto_HederaFunctionality) throws {
268283
switch proto {
@@ -349,9 +364,14 @@ public enum RequestType {
349364
case .tokenCancelAirdrop: self = .tokenCancelAirdrop
350365
case .tokenClaimAirdrop: self = .tokenClaimAirdrop
351366
case .stateSignatureTransaction: self = .stateSignatureTransaction
367+
case .hintsPreprocessingVote: self = .hintsPreprocessingVote
368+
case .hintsKeyPublication: self = .hintsKeyPublication
369+
case .hintsPartialSignature: self = .hintsPartialSignature
352370
case .historyAssemblySignature: self = .historyAssemblySignature
353371
case .historyProofKeyPublication: self = .historyProofKeyPublication
354372
case .historyProofVote: self = .historyProofVote
373+
case .crsPublication: self = .crsPublication
374+
case .atomicBatch: self = .atomicBatch
355375
case .UNRECOGNIZED(let code):
356376
throw HError.fromProtobuf("unrecognized RequestType: `\(code)`")
357377
}
@@ -441,9 +461,14 @@ public enum RequestType {
441461
case .tokenCancelAirdrop: return .tokenCancelAirdrop
442462
case .tokenClaimAirdrop: return .tokenClaimAirdrop
443463
case .stateSignatureTransaction: return .stateSignatureTransaction
464+
case .hintsPreprocessingVote: return .hintsPreprocessingVote
465+
case .hintsKeyPublication: return .hintsKeyPublication
466+
case .hintsPartialSignature: return .hintsPartialSignature
444467
case .historyAssemblySignature: return .historyAssemblySignature
445468
case .historyProofKeyPublication: return .historyProofKeyPublication
446469
case .historyProofVote: return .historyProofVote
470+
case .crsPublication: return .crsPublication
471+
case .atomicBatch: return .atomicBatch
447472
}
448473
}
449474
}

Sources/Hiero/Transaction/Transaction+FromProtobuf.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ extension Transaction {
215215
case .stateSignatureTransaction(let code):
216216
throw HError.fromProtobuf("unrecognized: stateSignatureTransaction `\(code)`")
217217

218+
case .hintsPreprocessingVote(let code):
219+
throw HError.fromProtobuf("unrecognized: hintsPreprocessingVote `\(code)`")
220+
221+
case .hintsKeyPublication(let code):
222+
throw HError.fromProtobuf("unrecognized: hintsKeyPublication `\(code)`")
223+
224+
case .hintsPartialSignature(let code):
225+
throw HError.fromProtobuf("unrecognized: hintsPartialSignature `\(code)`")
226+
218227
case .historyProofSignature(let code):
219228
throw HError.fromProtobuf("unrecognized: historyProofSignature `\(code)`")
220229

@@ -223,6 +232,12 @@ extension Transaction {
223232

224233
case .historyProofVote(let code):
225234
throw HError.fromProtobuf("unrecognized: historyProofVote `\(code)`")
235+
236+
case .crsPublication(let code):
237+
throw HError.fromProtobuf("unrecognized: crsPublication `\(code)`")
238+
239+
case .atomicBatch(let code):
240+
throw HError.fromProtobuf("unrecognized: atomicBatch `\(code)`")
226241
}
227242
}
228243
}

0 commit comments

Comments
 (0)