Skip to content

Commit

Permalink
Revert main files that were changed for no apparent reason
Browse files Browse the repository at this point in the history
  • Loading branch information
rh-concordium committed Jan 22, 2024
1 parent a9fcb5b commit e1d110d
Show file tree
Hide file tree
Showing 10 changed files with 670 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ DerivedData/
.swiftpm/configuration/registries.json
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
/ExampleWallet/.idea/
.idea/
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ let package = Package(
name: "ConcordiumSwiftSDK",
platforms: [
// To be kept in sync with README.
.macOS(.v10_15),
.iOS(.v15),
.macOS(.v10_15),
],
products: [
.library(
Expand Down
18 changes: 13 additions & 5 deletions Sources/ConcordiumSwiftSDK/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import GRPC
import NIOCore
import NIOPosix

class Client {
public class Client {
let grpc: Concordium_V2_QueriesNIOClient

init(channel: GRPCChannel) {
public init(channel: GRPCChannel) {
grpc = Concordium_V2_QueriesNIOClient(channel: channel)
}

func getCryptographicParameters(at block: BlockIdentifier) async throws -> CryptographicParameters {
public func getCryptographicParameters(at block: BlockIdentifier) async throws -> CryptographicParameters {
let req = block.toGrpcType()
let res = try await grpc.getCryptographicParameters(req).response.get()
return CryptographicParameters(
Expand All @@ -20,13 +20,21 @@ class Client {
)
}

func getNextAccountSequenceNumber(of address: AccountAddress) async throws -> NextAccountSequenceNumber {
public func getNextAccountSequenceNumber(of address: AccountAddress) async throws -> NextAccountSequenceNumber {
var req = Concordium_V2_AccountAddress()
req.value = address.bytes
let res = try await grpc.getNextAccountSequenceNumber(req).response.get()
return NextAccountSequenceNumber(
sequenceNumber: res.sequenceNumber.value,
sequenceNumber: res.hasSequenceNumber ? res.sequenceNumber.value : nil,
allFinal: res.allFinal
)
}

public func getAccountInfo(of account: AccountIdentifier, at block: BlockIdentifier) async throws -> AccountInfo {
var req = Concordium_V2_AccountInfoRequest()
req.accountIdentifier = account.toGrpcType()
req.blockHash = block.toGrpcType()
let res = try await grpc.getAccountInfo(req).response.get()
return try .fromGrpcType(res)
}
}
8 changes: 4 additions & 4 deletions Sources/ConcordiumSwiftSDK/Extensions/Data+Helper.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Foundation

enum DataError: Error {
public enum DataError: Error {
case invalidHexString
}

// Courtesy of ChatGPT ¯\_(ツ)_/¯

extension Data {
public extension Data {
init(fromHexString hex: String) throws {
let length = hex.count / 2
var data = Data(capacity: length)
Expand All @@ -22,7 +22,7 @@ extension Data {
self = data
}

public func hexadecimalString() -> String {
return map { String(format: "%02hhx", $0) }.joined()
func hexadecimalString() -> String {
map { String(format: "%02hhx", $0) }.joined()
}
}
Loading

0 comments on commit e1d110d

Please sign in to comment.