Skip to content

Commit

Permalink
Implement getIdentityProviderInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
bisgardo committed Feb 26, 2024
1 parent bffd02a commit 1b6be13
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 2 deletions.
47 changes: 47 additions & 0 deletions Sources/ConcordiumSwiftSdk/WalletProxyClient.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import Foundation

public class WalletProxyClient {
let baseUrl: String

public init(baseUrl: String) {
self.baseUrl = baseUrl
}

public func getIdentityProviderInfo() async throws -> [IdentityProviderJson] {
let url = URL(string: "\(baseUrl)/v1/ip_info")!
let (data, _) = try await URLSession.shared.data(from: url)
return try JSONDecoder().decode([IdentityProviderJson].self, from: data)
}
}

public struct IdentityProviderJson: Decodable {
public var ipInfo: IdentityProvider
public var arsInfos: [String: AnonymityRevoker]
public var metadata: Metadata

public struct IdentityProvider: Decodable {
public var ipIdentity: UInt32
public var ipDescription: Description
public var ipCdiVerifyKey: String
public var ipVerifyKey: String
}

public struct AnonymityRevoker: Decodable {
public var arIdentity: UInt32
public var arDescription: Description
public var arPublicKey: String
}

public struct Description: Decodable {
public var name: String
public var description: String
public var url: String
}

public struct Metadata: Decodable {
public var icon: String
public var issuanceStart: String
public var support: String?
public var recoveryStart: String
}
}
26 changes: 24 additions & 2 deletions examples/GrpcCli/Sources/GrpcCli/GrpcCli.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct GrpcCli: AsyncParsableCommand {
static var configuration = CommandConfiguration(
abstract: "A CLI for demonstrating and testing use of the gRPC client of the SDK.",
version: "1.0.0",
subcommands: [CryptographicParameters.self, Account.self, Wallet.self, LegacyWallet.self]
subcommands: [CryptographicParameters.self, Account.self, Wallet.self, LegacyWallet.self, Identity.self]
)

struct CryptographicParameters: AsyncParsableCommand {
Expand Down Expand Up @@ -197,7 +197,7 @@ struct GrpcCli: AsyncParsableCommand {
).generateAccount(
credentials: [
AccountCredential(
identity: Identity(providerIndex: walletCli.identityProviderIndex, index: walletCli.identityIndex),
identity: ConcordiumSwiftSdk.Identity(providerIndex: walletCli.identityProviderIndex, index: walletCli.identityIndex),
counter: walletCli.credentialCounter
),
]
Expand Down Expand Up @@ -270,6 +270,28 @@ struct GrpcCli: AsyncParsableCommand {
}
}
}

struct Identity: AsyncParsableCommand {
static var configuration = CommandConfiguration(
abstract: "Commands related to identity management.",
subcommands: [Providers.self]
)

struct Providers: AsyncParsableCommand {
static var configuration = CommandConfiguration(
abstract: "List all Identity Providers."
)

@Option(help: "Base URL of WalletProxy instance.")
var walletProxyBaseUrl: String = "https://wallet-proxy.testnet.concordium.com"

func run() async throws {
let wp = WalletProxyClient(baseUrl: walletProxyBaseUrl)
let res = try await wp.getIdentityProviderInfo()
print(res)
}
}
}
}

func transfer(client: NodeClientProtocol, sender: WalletAccount, receiver: AccountAddress, amount: MicroCcdAmount, expiry: TransactionTime) async throws -> TransactionHash {
Expand Down

0 comments on commit 1b6be13

Please sign in to comment.