Skip to content

Update packages #453

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
23 changes: 2 additions & 21 deletions Examples/AccountAlias/main.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: Apache-2.0
import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -84,22 +84,3 @@ internal enum Program {
print("Example complete!")
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/AccountAllowance/main.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0

import Hiero
import SwiftDotenv
import HieroExampleUtilities

private struct Account {
internal let key: PrivateKey
Expand Down Expand Up @@ -183,7 +183,7 @@ private func cleanUp(
@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand All @@ -193,22 +193,3 @@ internal enum Program {
try await cleanUp(client, env.operatorAccountId, accounts)
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 3 additions & 20 deletions Examples/AddNftAllowance/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

import Foundation
import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -123,8 +123,8 @@ internal enum Program {
// Step 6: Transfer NFT using approved allowance
let transferReceipt = try await TransferTransaction()
.approvedNftTransfer(NftId(tokenId: nftTokenId, serial: 1), env.operatorAccountId, receiverAccountId)
.freezeWith(client)
.transactionId(TransactionId.generateFrom(spenderAccountId))
.freezeWith(client)
.sign(spenderKey)
.execute(client)
.getReceipt(client)
Expand Down Expand Up @@ -155,20 +155,3 @@ internal enum Program {
// Implement cleanup steps...
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the Hiero network this example should run against.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/ConsensusPubSub/main.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0

import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -55,22 +55,3 @@ internal enum Program {
}
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
33 changes: 7 additions & 26 deletions Examples/ConsensusPubSubChunked/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import Foundation
import Hiero
import HieroExampleUtilities
import SwiftDotenv

@main
internal enum Program {
internal static func main() async throws {

let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -50,14 +48,16 @@ internal enum Program {

// now pretend we sent those bytes across the network
// parse them into a transaction so we can sign as the submit key
let deserializedTransaction = try Transaction.fromBytes(transactionBytes) as! TopicMessageSubmitTransaction

let deserializedTransaction = try Transaction.fromBytes(transactionBytes)
guard let topicMessageSubmitTransaction = deserializedTransaction as? TopicMessageSubmitTransaction else {
fatalError("Expected TopicMessageSubmitTransaction")
}
// sign with that submit key
deserializedTransaction.sign(submitKey)
topicMessageSubmitTransaction.sign(submitKey)

// now actually submit the transaction
// get the receipt to ensure there were no errors
_ = try await deserializedTransaction.execute(client).getReceipt(client)
_ = try await topicMessageSubmitTransaction.execute(client).getReceipt(client)

print("Finished sending the message, press ctrl+c to exit once it's recieved")
}
Expand All @@ -74,22 +74,3 @@ internal enum Program {
}
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/ConsensusPubSubWithSubmitKey/main.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0

import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -61,22 +61,3 @@ internal enum Program {
}
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/CreateAccount/main.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0

import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand All @@ -27,22 +27,3 @@ internal enum Program {
print("account address = \(newAccountId)")
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/CreateAccountThresholdKey/main.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// SPDX-License-Identifier: Apache-2.0

import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -63,22 +63,3 @@ internal enum Program {
print("account balance after transfer: \(balanceAfter)")
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
23 changes: 2 additions & 21 deletions Examples/CreateAccountWithAlias/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

import Foundation
import Hiero
import SwiftDotenv
import HieroExampleUtilities

@main
internal enum Program {
internal static func main() async throws {
print("Starting Example")
let env = try Dotenv.load()
let env = try Environment.load()
let client = try Client.forName(env.networkName)

client.setOperator(env.operatorAccountId, env.operatorKey)
Expand Down Expand Up @@ -145,22 +145,3 @@ internal enum Program {
return true
}
}

extension Environment {
/// Account ID for the operator to use in this example.
internal var operatorAccountId: AccountId {
AccountId(self["OPERATOR_ID"]!.stringValue)!
}

/// Private key for the operator to use in this example.
internal var operatorKey: PrivateKey {
PrivateKey(self["OPERATOR_KEY"]!.stringValue)!
}

/// The name of the hedera network this example should be ran against.
///
/// Testnet by default.
internal var networkName: String {
self["HEDERA_NETWORK"]?.stringValue ?? "testnet"
}
}
Loading
Loading