Skip to content

Commit

Permalink
gRPC: Implement endpoint 'getAccountInfo' (#2)
Browse files Browse the repository at this point in the history
Added `getAccountInfo` to `Client` along with wrappers for all related generated types to keep it from being too unpleasant to work with.

Resolves https://concordium.atlassian.net/browse/CBW-1563.
  • Loading branch information
bisgardo authored Jan 17, 2024
1 parent b4e2b4f commit a6aced4
Show file tree
Hide file tree
Showing 7 changed files with 659 additions and 6 deletions.
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
10 changes: 9 additions & 1 deletion Sources/ConcordiumSwiftSDK/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ class Client {
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
)
}

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)
}
}
Loading

0 comments on commit a6aced4

Please sign in to comment.