Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
e596ad8
fix: tests for e2e testing in CI
rwalworth Aug 29, 2025
d0ed23b
refactor: format
rwalworth Aug 29, 2025
f98e966
Merge branch 'main' into 00424-add-ci-support-for-testing-with-the-so…
rwalworth Aug 29, 2025
4ebf330
refactor: formatting
rwalworth Aug 29, 2025
950d74e
ci: add setup step
rwalworth Aug 29, 2025
3ffbc9a
ci: trying running e2e tests on linux
rwalworth Aug 29, 2025
ed3c0d5
ci: try building on linux
rwalworth Aug 29, 2025
3865844
ci: try setting up solo manually
rwalworth Aug 29, 2025
bc01ddb
ci: setup kind
rwalworth Aug 29, 2025
883b158
ci: just try local node
rwalworth Sep 4, 2025
0cc1a7b
ci: install coreutils for sha256sum command
rwalworth Sep 4, 2025
db7e6b0
ci: try installing docker
rwalworth Sep 4, 2025
9264b21
ci: don't use colima
rwalworth Sep 4, 2025
683a2d0
ci: try chatgpt workflow
rwalworth Sep 4, 2025
1389534
ci: only do one build for now
rwalworth Sep 4, 2025
730b41e
ci: try macos13 where colima can run
rwalworth Sep 4, 2025
6c27707
fix unhappy arch step
rwalworth Sep 4, 2025
fa2cf86
ci: remove docker pull explicit image
rwalworth Sep 4, 2025
9e9b6d4
ci: try docker desktop
rwalworth Sep 4, 2025
5144f28
ci: install docker with privileged components and accept license
rwalworth Sep 4, 2025
ce1348d
ci: wait for docker to become ready
rwalworth Sep 5, 2025
36df2e2
ci: fix env vars
rwalworth Sep 5, 2025
17c8b28
ci: run e2e tests
rwalworth Sep 5, 2025
a54fa96
ci: env didn't take
rwalworth Sep 5, 2025
191783d
ci: fill in all environment variables
rwalworth Sep 5, 2025
f86b112
ci: write .env file
rwalworth Sep 5, 2025
9777e31
ci: actually write the .env file properly
rwalworth Sep 5, 2025
881e379
ci: .env file being written weirdly?
rwalworth Sep 5, 2025
de25117
ci: try lima instead of docker desktop
rwalworth Sep 17, 2025
f5ad51e
ci: try colima again
rwalworth Sep 17, 2025
ee3a22f
ci: colima may have gotten deleted
rwalworth Sep 17, 2025
43ef527
ci: don't need to check runner os
rwalworth Sep 17, 2025
b742bc4
ci: get kind logs
rwalworth Sep 30, 2025
01514b8
Merge branch 'main' into 00424-add-ci-support-for-testing-with-the-so…
rwalworth Oct 1, 2025
f5396de
ci: try anything
rwalworth Oct 1, 2025
e465316
ci: fix indentation
rwalworth Oct 1, 2025
d4717e6
ci: fix
rwalworth Oct 1, 2025
8ab3d63
ci: remove npm ci step
rwalworth Oct 1, 2025
84e9519
ci: revert
rwalworth Oct 1, 2025
1594964
ci: update kind image
rwalworth Oct 1, 2025
4644cf5
ci: update kind image
rwalworth Oct 1, 2025
11c8011
ci: update kind image
rwalworth Oct 1, 2025
d303c1d
ci: don't use kind image
rwalworth Oct 1, 2025
7709d9d
ci: fix
rwalworth Oct 1, 2025
691c646
ci: revert back to working file
rwalworth Oct 2, 2025
9b7e29d
ci: add port forward step
rwalworth Oct 3, 2025
a5f1ce6
ci: keep trying stuff
rwalworth Oct 3, 2025
089e267
ci: plz wooooork
rwalworth Oct 3, 2025
fc85004
ci: try try try
rwalworth Oct 3, 2025
f78457c
ci: remove cluster-ref flags
rwalworth Oct 13, 2025
a9f866a
ci: upgrade to solo v0.47.0
rwalworth Oct 16, 2025
2e7d41d
ci: increase colima resources
rwalworth Oct 16, 2025
b69089e
ci: revert resources change
rwalworth Oct 17, 2025
49cc815
ci: build on linux
rwalworth Oct 22, 2025
84cfa82
ci: comment out solo stuff for a second, make sure can build sdk
rwalworth Oct 22, 2025
4cfa191
ci: add linux build issue
rwalworth Oct 22, 2025
283434e
ci: still figuring out linux build
rwalworth Oct 22, 2025
8a4e6e9
ci: linux build
rwalworth Oct 22, 2025
4d23235
ci: just work already
rwalworth Oct 22, 2025
cc68eb8
ci: work work work work work - Rihanna
rwalworth Oct 22, 2025
cd4836d
ci: come on already
rwalworth Oct 22, 2025
c308de6
ci: keep on trying
rwalworth Oct 22, 2025
cdabc8b
ci: rewrite more files
rwalworth Oct 22, 2025
fae80f3
format
rwalworth Oct 22, 2025
4dbe2be
ci: try things
rwalworth Oct 23, 2025
61ecc27
ci: try different setup swift action
rwalworth Oct 23, 2025
96d3e4a
ci: enable DAB tests in separate job
rwalworth Nov 5, 2025
13d2684
refactor: update to non-deprecated snapshot call
rwalworth Nov 9, 2025
379dc84
ci: try again
rwalworth Nov 10, 2025
7cf0f5b
ci: don't require import Network
rwalworth Nov 10, 2025
2841419
ci: need different module for linux networking
rwalworth Nov 10, 2025
b8edf57
ci: URLSession async api for linux
rwalworth Nov 10, 2025
d752abb
ci: add explicit type annotation for linux urlsession
rwalworth Nov 10, 2025
b40b43e
ci: simplify build
rwalworth Nov 10, 2025
ca55ada
ci: remove network import and xctsource code context
rwalworth Nov 10, 2025
105519b
ci: prepare solo and format
rwalworth Nov 10, 2025
4a4976e
ci: testing e2e tests
rwalworth Nov 10, 2025
45c1ab8
ci: write .env file for tests
rwalworth Nov 10, 2025
728e59f
ci: enable all builds and tests
rwalworth Nov 10, 2025
b73face
chore: upgrade protobufs to v0.68
rwalworth Nov 10, 2025
bbef71b
ci: fix 4 failing integration tests
rwalworth Nov 10, 2025
ca4cd87
ci: fix format job
rwalworth Nov 10, 2025
f0fdf85
ci: enable previous versions
rwalworth Nov 10, 2025
11edfce
ci: rename job
rwalworth Nov 10, 2025
d7afff8
ci: add back 5.10 swift
rwalworth Nov 10, 2025
6a11b96
ci: update workflow
rwalworth Nov 10, 2025
7706e70
fix: tests
rwalworth Nov 10, 2025
ce249b9
refactor: formatting
rwalworth Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
136 changes: 87 additions & 49 deletions .github/workflows/swift-ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Swift CI
on:
pull_request:
push:
push:
branches: ['main']

defaults:
Expand All @@ -13,7 +13,8 @@ permissions:

jobs:
format:
runs-on: macos-latest
name: Format (lint)
runs-on: hiero-client-sdk-linux-large
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
Expand All @@ -23,73 +24,110 @@ jobs:
- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install swift-format
run: brew install swift-format

- name: Format
run: swift format lint --strict --configuration .swift-format.json --recursive --parallel Sources/ Tests/ Examples/ Package.swift

build:
strategy:
matrix:
swift: ["5.9", "5.10"]
os: [macos-13, macos-14]

runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit

- name: Setup Swift
uses: swift-actions/setup-swift@3aed395c5397f62deb91d8fe7af1418a9ae4d16f # v2.1.0
- name: Install system deps for Swift
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y \
git curl unzip xz-utils ca-certificates pkg-config \
clang libicu-dev libxml2-dev libsqlite3-dev zlib1g-dev \
libcurl4-openssl-dev libssl-dev

- name: Setup Swift (toolchain)
uses: SwiftyLab/setup-swift@4bbb093f8c68d1dee1caa8b67c681a3f8fe70a91 # v1.12.0
with:
swift-version: ${{ matrix.swift }}

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Cache
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
with:
path: sdk/swift/.build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-

- name: Build
run: swift build
swift-version: '5.9'

- name: Build swift-format
run: |
set -euxo pipefail
git clone --depth=1 https://github.com/apple/swift-format.git .swift-format-src
pushd .swift-format-src
swift build -c release
echo "$PWD/.build/release" >> $GITHUB_PATH
popd
swift-format --version || true

- name: Format (lint)
run: |
swift-format lint --strict --configuration .swift-format.json --recursive --parallel Sources/ Tests/ Examples/ Package.swift

test:
name: Build and Test SDK
strategy:
matrix:
swift: ["5.9", "5.10"]
os: [macos-13, macos-14]
runs-on: hiero-client-sdk-linux-large
env:
SOLO_CLUSTER_NAME: solo
SOLO_NAMESPACE: solo
SOLO_CLUSTER_SETUP_NAMESPACE: solo-cluster
SOLO_DEPLOYMENT: solo-deployment
KIND_IMAGE: kindest/node:v1.32.2 # pin to a stable image

needs: [build]
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f
with:
egress-policy: audit

- name: Setup Swift
uses: swift-actions/setup-swift@3aed395c5397f62deb91d8fe7af1418a9ae4d16f # v2.1.0
uses: SwiftyLab/setup-swift@4bbb093f8c68d1dee1caa8b67c681a3f8fe70a91 # v1.12.0
with:
swift-version: ${{ matrix.swift }}

- name: Checkout Code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- name: Cache Code
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
- name: Cache SPM build dir
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: sdk/swift/.build
path: .build
key: ${{ runner.os }}-${{ matrix.swift }}-spm-${{ github.job }}-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-${{ matrix.swift }}-spm-

- name: Test
run: swift test
- name: Install system dependencies for Swift/gRPC
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y \
git curl jq coreutils ca-certificates \
clang libicu-dev libxml2-dev libsqlite3-dev zlib1g-dev \
libcurl4-openssl-dev libssl-dev pkg-config \
protobuf-compiler

- name: Verify Swift installation
run: |
swift --version
which swift
swift package --version

- name: Build SDK and TCK
run: |
swift build

- name: Run unit tests (HieroTests)
run: swift test --filter HieroTests

- name: Prepare Hiero Solo
id: solo
uses: hiero-ledger/hiero-solo-action@6a1a77601cf3e69661fb6880530a4edf656b40d5 # v0.14.0
with:
installMirrorNode: true
mirrorNodeVersion: v0.142.0
hieroVersion: v0.68.0

- name: Write .env for tests
run: |
umask 077
{
echo "TEST_NETWORK_NAME=localhost"
echo "TEST_RUN_NONFREE=1"
echo "TEST_OPERATOR_ID=0.0.2"
echo "TEST_OPERATOR_KEY=302e020100300506032b65700422042091132178e72057a1d7528025956fe39b0b847f200ab59b2fdd367017f3087137"
} > .env
cat .env

- name: Run integration tests (HieroE2ETests)
run: swift test --filter HieroE2ETests
1 change: 0 additions & 1 deletion Examples/CreateUpdateDeleteNode/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import Foundation
import Hiero
import HieroExampleUtilities
import Network
import SwiftDotenv

// Set the paths **HERE** for the json files provided by solo.
Expand Down
9 changes: 9 additions & 0 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ let package = Package(
.package(url: "https://github.com/attaswift/BigInt.git", .upToNextMajor(from: "5.2.0")),
// Currently, only used for keccak256
.package(url: "https://github.com/krzyzanowskim/OpenSSL-Package.git", .upToNextMajor(from: "3.3.2000")),
.package(url: "https://github.com/krzyzanowskim/CryptoSwift.git", from: "1.8.0"),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "3.0.0")),
],
targets: [
.target(
Expand Down Expand Up @@ -140,6 +142,8 @@ let package = Package(
.product(name: "secp256k1", package: "secp256k1.swift"),
.product(name: "BigInt", package: "BigInt"),
.product(name: "OpenSSL", package: "OpenSSL-Package"),
.product(name: "CryptoSwift", package: "CryptoSwift"),
.product(name: "Crypto", package: "swift-crypto"),
]
// todo: find some way to enable these locally.
// swiftSettings: [
Expand Down
12 changes: 12 additions & 0 deletions Sources/Hiero/AnyTransaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ internal enum ServicesTransactionDataList {
case hintsPartialSignature([Com_Hedera_Hapi_Services_Auxiliary_Hints_HintsPartialSignatureTransactionBody])
case crsPublication([Com_Hedera_Hapi_Services_Auxiliary_Hints_CrsPublicationTransactionBody])
case atomicBatch([Proto_AtomicBatchTransactionBody])
case lambdaSstore([Com_Hedera_Hapi_Node_Hooks_LambdaSStoreTransactionBody])
case hookDispatch([Com_Hedera_Hapi_Node_Hooks_HookDispatchTransactionBody])

internal mutating func append(_ transaction: Proto_TransactionBody.OneOf_Data) throws {
switch (self, transaction) {
Expand Down Expand Up @@ -298,6 +300,14 @@ internal enum ServicesTransactionDataList {
array.append(data)
self = .atomicBatch(array)

case (.lambdaSstore(var array), .lambdaSstore(let data)):
array.append(data)
self = .lambdaSstore(array)

case (.hookDispatch(var array), .hookDispatch(let data)):
array.append(data)
self = .hookDispatch(array)

default:
throw HError.fromProtobuf("mismatched transaction types")
}
Expand Down Expand Up @@ -370,6 +380,8 @@ extension ServicesTransactionDataList: TryFromProtobuf {
case .tokenCancelAirdrop(let data): value = .tokenCancelAirdrop([data])
case .tokenClaimAirdrop(let data): value = .tokenClaimAirdrop([data])
case .atomicBatch(let data): value = .atomicBatch([data])
case .lambdaSstore(let data): value = .lambdaSstore([data])
case .hookDispatch(let data): value = .hookDispatch([data])
case .stateSignatureTransaction:
throw HError.fromProtobuf("Unsupported transaction `StateSignatureTransaction`")
case .hintsPreprocessingVote:
Expand Down
8 changes: 4 additions & 4 deletions Sources/Hiero/Client/ManagedNetwork.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ internal actor NetworkUpdateTask: Sendable {
self.managedNetwork = managedNetwork
self.eventLoop = eventLoop

if let updatePeriod {
task = Self.makeTask(
eventLoop, managedNetwork, ManagedNetwork.networkFirstUpdateDelay, updatePeriod, shard, realm)
}
// if let updatePeriod {
// task = Self.makeTask(
// eventLoop, managedNetwork, ManagedNetwork.networkFirstUpdateDelay, updatePeriod, shard, realm)
// }
}

private static func makeTask(
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hiero/Contract/ContractFunctionSelector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private struct KeccakHasher {
}

mutating func finalize() -> Data {
let output = Crypto.Sha3.keccak256(buffer!)
let output = CryptoNamespace.Sha3.keccak256(buffer!)
buffer = nil

return output
Expand Down
24 changes: 23 additions & 1 deletion Sources/Hiero/Contract/MirrorNodeContractQuery.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Foundation
import GRPC
import HieroProtobufs

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif

/// MirrorNodeContractQuery returns a result from EVM execution such as cost-free execution of read-only smart
/// contract queries, gas estimation, and transient simulations of read-write operations.
public class MirrorNodeContractQuery: ValidateChecksums {
Expand Down Expand Up @@ -107,7 +111,25 @@ public class MirrorNodeContractQuery: ValidateChecksums {
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

/// Send the request.
let (data, response) = try await URLSession.shared.data(for: request)
#if canImport(FoundationNetworking)
// Linux: Use callback-based API wrapped in continuation
let (data, response): (Data, URLResponse) = try await withCheckedThrowingContinuation { continuation in
URLSession.shared.dataTask(with: request) { data, response, error in
if let error = error {
continuation.resume(throwing: error)
return
}
guard let data = data, let response = response else {
continuation.resume(throwing: URLError(.badServerResponse))
return
}
continuation.resume(returning: (data, response))
}.resume()
}
#else
// macOS/iOS: Use modern async/await API
let (data, response) = try await URLSession.shared.data(for: request)
#endif

/// Make sure a good response was returned.
guard let httpResponse = response as? HTTPURLResponse,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Hiero/Crypto/Crypto+k256Digest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

import secp256k1

extension Crypto {
extension CryptoNamespace {
internal typealias SecpDigest = Digest
}
34 changes: 29 additions & 5 deletions Sources/Hiero/Crypto/Crypto.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
// SPDX-License-Identifier: Apache-2.0

// used as a namespace
internal enum Crypto {}
// MARK: - Crypto Namespace
//
// This file defines the `CryptoNamespace` enum, which serves as a namespace
// for organizing cryptographic functionality used throughout the Hiero SDK.
//
// The namespace pattern avoids polluting the global namespace with generic names
// like "Aes" or "Hmac", and provides a clear organizational structure for
// crypto-related code.
//
// Extensions in other files add functionality to this namespace:
// - CryptoAes.swift: AES encryption/decryption
// - CryptoSha2.swift: SHA-256, SHA-384, SHA-512
// - CryptoSha3.swift: Keccak-256
// - Crypto+k256Digest.swift: secp256k1 digest types

extension Crypto {
/// Namespace for cryptographic primitives used by the Hiero SDK.
///
/// This enum is never instantiated - it exists solely as a namespace to
/// organize cryptographic functionality.
internal enum CryptoNamespace {}

// MARK: - HMAC Algorithm Selection

extension CryptoNamespace {
/// HMAC (Hash-based Message Authentication Code) algorithm variants.
///
/// Specifies which hash function to use with HMAC for key derivation
/// and message authentication.
internal enum Hmac {
// case sha1
case sha2(Crypto.Sha2)
/// HMAC using a SHA-2 family hash function.
case sha2(CryptoNamespace.Sha2)
}
}
Loading