Skip to content

Commit

Permalink
Merge branch 'mobile-wallet-feature-parity' into cis2-client
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenbf committed Oct 9, 2024
2 parents 6b89d87 + 4085335 commit 8aa432c
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Sources/Concordium/Domain/Account.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ extension VerifyKey: Codable {
}
}

extension VerifyKey: @retroactive CustomStringConvertible {
extension ConcordiumWalletCrypto.VerifyKey: Swift.CustomStringConvertible {
public var description: String { "\(key.hex)" }
}

Expand Down
14 changes: 7 additions & 7 deletions Sources/Concordium/Domain/Identity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ extension AnonymityRevokerInfo: FromGRPC {
}
}

extension IdentityObject: @retroactive Decodable {
extension ConcordiumWalletCrypto.IdentityObject: Swift.Decodable {
enum CodingKeys: CodingKey {
case preIdentityObject
case attributeList
Expand All @@ -60,7 +60,7 @@ extension IdentityObject: @retroactive Decodable {
}
}

extension PreIdentityObject: @retroactive Decodable {
extension ConcordiumWalletCrypto.PreIdentityObject: Swift.Decodable {
enum CodingKeys: CodingKey {
case idCredPub
case ipArData
Expand Down Expand Up @@ -90,7 +90,7 @@ extension PreIdentityObject: @retroactive Decodable {
}
}

extension AnonymityRevokerData: @retroactive Decodable {
extension ConcordiumWalletCrypto.ArData: Swift.Decodable {
enum CodingKeys: CodingKey {
case encPrfKeyShare
case proofComEncEq
Expand All @@ -105,7 +105,7 @@ extension AnonymityRevokerData: @retroactive Decodable {
}
}

extension ChoiceArParameters: @retroactive Decodable {
extension ConcordiumWalletCrypto.ChoiceArParameters: Swift.Decodable {
enum CodingKeys: CodingKey {
case arIdentities
case threshold
Expand All @@ -120,7 +120,7 @@ extension ChoiceArParameters: @retroactive Decodable {
}
}

extension AttributeList: @retroactive Decodable {
extension ConcordiumWalletCrypto.AttributeList: Swift.Decodable {
enum CodingKeys: CodingKey {
case validTo
case createdAt
Expand All @@ -145,7 +145,7 @@ extension Description: FromGRPC {
}
}

extension Description: @retroactive Decodable {
extension ConcordiumWalletCrypto.Description: Swift.Decodable {
/// Fields used in Wallet Proxy response.
enum CodingKeys: CodingKey {
case name
Expand Down Expand Up @@ -285,7 +285,7 @@ public struct IdentityRecoveryError: Decodable, Error {
/// [here](https://docs.google.com/spreadsheets/d/1CxpFvtAoUcylHQyeBtRBaRt1zsibtpmQOVsk7bsHPGA/edit).
public typealias AttributeTag = ConcordiumWalletCrypto.AttributeTag

extension AttributeTag: @retroactive CustomStringConvertible, @retroactive CaseIterable, @retroactive CodingKeyRepresentable {
extension ConcordiumWalletCrypto.AttributeTag: Swift.CustomStringConvertible, Swift.CaseIterable, Swift.CodingKeyRepresentable {
public enum CodingKeys: CodingKey {
case firstName
case lastName
Expand Down
2 changes: 1 addition & 1 deletion Sources/Concordium/Domain/Queries.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extension CryptographicParameters: FromGRPC {
}
}

extension CryptographicParameters: @retroactive Decodable {
extension ConcordiumWalletCrypto.GlobalContext: Swift.Decodable {
private enum CodingKeys: CodingKey {
case onChainCommitmentKey
case bulletproofGenerators
Expand Down
38 changes: 20 additions & 18 deletions Sources/Concordium/Domain/Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NIO
/// Describes the official public networks available for the concordium blockchain
public typealias Network = ConcordiumWalletCrypto.Network

extension Network: @retroactive Codable {
extension ConcordiumWalletCrypto.Network: Swift.Codable {
private enum JSON: String, Codable {
case mainnet
case testnet
Expand Down Expand Up @@ -414,22 +414,7 @@ extension ScheduledTransfer: FromGRPC {
/// Represents a contract address on chain
public typealias ContractAddress = ConcordiumWalletCrypto.ContractAddress

extension ContractAddress: FromGRPC, ToGRPC, @retroactive Codable {
public func encode(to encoder: any Encoder) throws {
try JSON(index: index, subindex: subindex).encode(to: encoder)
}

public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()
let value = try container.decode(JSON.self)
self = .init(index: value.index, subindex: value.subindex)
}

struct JSON: Codable {
var index: UInt64
var subindex: UInt64
}

extension ContractAddress: FromGRPC, ToGRPC {
func toGRPC() -> Concordium_V2_ContractAddress {
var g = GRPC()
g.index = index
Expand Down Expand Up @@ -464,7 +449,24 @@ extension ContractAddress: Serialize, Deserialize, ContractSerialize, ContractDe
}
}

extension ContractAddress: @retroactive CustomStringConvertible {
extension ConcordiumWalletCrypto.ContractAddress: Swift.Codable {
public func encode(to encoder: any Encoder) throws {
try JSON(index: index, subindex: subindex).encode(to: encoder)
}

public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()
let value = try container.decode(JSON.self)
self = .init(index: value.index, subindex: value.subindex)
}

struct JSON: Codable {
var index: UInt64
var subindex: UInt64
}
}

extension ConcordiumWalletCrypto.ContractAddress: Swift.CustomStringConvertible {
public var description: String {
"<\(index),\(subindex)>"
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/Concordium/Proofs/Id.swift
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ extension AtomicIdentityStatement {
}
}

extension AtomicIdentityStatement: @retroactive Codable {
extension ConcordiumWalletCrypto.AtomicIdentityStatement: Swift.Codable {
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(toSDK())
Expand Down Expand Up @@ -329,7 +329,7 @@ extension AtomicIdentityProof {
}
}

extension AtomicIdentityProof: @retroactive Codable {
extension ConcordiumWalletCrypto.AtomicIdentityProof: Swift.Codable {
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(toSDK())
Expand All @@ -346,7 +346,7 @@ extension AtomicIdentityProof: @retroactive Codable {
*/
public typealias IdentityProof = ConcordiumWalletCrypto.IdentityProof

extension IdentityProof: @retroactive Codable {
extension ConcordiumWalletCrypto.IdentityProof: Swift.Codable {
private struct JSON: Codable {
let proofs: [AtomicIdentityProof]
}
Expand All @@ -368,7 +368,7 @@ extension IdentityProof: @retroactive Codable {
*/
public typealias VersionedIdentityProof = ConcordiumWalletCrypto.VersionedIdentityProof

extension VersionedIdentityProof: @retroactive Codable {
extension ConcordiumWalletCrypto.VersionedIdentityProof: Swift.Codable {
private typealias JSON = Versioned<IdentityProof>

public func encode(to encoder: any Encoder) throws {
Expand Down
16 changes: 8 additions & 8 deletions Sources/Concordium/Proofs/Web3Id.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
/// proofs.
public typealias Web3IdAttribute = ConcordiumWalletCrypto.Web3IdAttribute

extension Web3IdAttribute: @retroactive Codable {
extension ConcordiumWalletCrypto.Web3IdAttribute: Swift.Codable {
private enum AttributeType: String, Codable {
case dateTime = "date-time"
}
Expand Down Expand Up @@ -130,7 +130,7 @@ extension AtomicWeb3IdStatement {
}
}

extension AtomicWeb3IdStatement: @retroactive Codable {
extension ConcordiumWalletCrypto.AtomicWeb3IdStatement: Swift.Codable {
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(toSDK())
Expand Down Expand Up @@ -161,7 +161,7 @@ public typealias Web3IdStatementWithProof = ConcordiumWalletCrypto.Web3IdStateme
/// Commitments signed by the issuer.
public typealias SignedCommitments = ConcordiumWalletCrypto.SignedCommitments

extension SignedCommitments: @retroactive Codable {
extension ConcordiumWalletCrypto.SignedCommitments: Swift.Codable {
private struct JSON: Codable {
let signature: String // HexString
let commitments: [String: String] // [String: HexString]
Expand All @@ -188,7 +188,7 @@ extension SignedCommitments: @retroactive Codable {
/// Describes the differnet decentralized identifier variants
public typealias DID = ConcordiumWalletCrypto.Did

extension DID: @retroactive Codable {
extension ConcordiumWalletCrypto.Did: Swift.Codable {
public init(from decoder: any Decoder) throws {
let container = try decoder.singleValueContainer()
let value = try container.decode(String.self)
Expand All @@ -215,7 +215,7 @@ func getDateFormatter() -> ISO8601DateFormatter {
* `Account` proof.
*/
public typealias VerifiableCredentialProof = ConcordiumWalletCrypto.VerifiableCredentialProof
extension VerifiableCredentialProof: @retroactive Codable {
extension ConcordiumWalletCrypto.VerifiableCredentialProof: Swift.Codable {
private enum CodingKeys: CodingKey {
case credentialSubject
case type
Expand Down Expand Up @@ -370,7 +370,7 @@ extension VerifiableCredentialProof: @retroactive Codable {
/// the presentation. At present this is a list of signatures.
public typealias LinkingProof = ConcordiumWalletCrypto.LinkingProof

extension LinkingProof: @retroactive Codable {
extension ConcordiumWalletCrypto.LinkingProof: Swift.Codable {
private struct JSON: Codable {
/// Always "ConcordiumWeakLinkingProofV1"
let type: String
Expand Down Expand Up @@ -423,7 +423,7 @@ public extension VerifiablePresentation {
}
}

extension VerifiablePresentation: @retroactive Codable {
extension ConcordiumWalletCrypto.VerifiablePresentation: Swift.Codable {
private struct JSON: Codable {
/// Always "VerifiablePresentation"
let type: String
Expand Down Expand Up @@ -798,7 +798,7 @@ extension AtomicWeb3IdProof {
}
}

extension AtomicWeb3IdProof: @retroactive Codable {
extension ConcordiumWalletCrypto.AtomicWeb3IdProof: Swift.Codable {
public func encode(to encoder: any Encoder) throws {
var container = encoder.singleValueContainer()
try container.encode(toSDK())
Expand Down
10 changes: 5 additions & 5 deletions examples/CLI/Sources/ConcordiumExampleClient/commands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct WalletProxyOptions: ParsableArguments {
}
}

extension BlockIdentifier: @retroactive ExpressibleByArgument {
extension Concordium.BlockIdentifier: ArgumentParser.ExpressibleByArgument {
public init?(argument: String) {
do {
self = try .hash(BlockHash(fromHex: argument))
Expand All @@ -40,7 +40,7 @@ extension BlockIdentifier: @retroactive ExpressibleByArgument {
}
}

extension AccountAddress: @retroactive ExpressibleByArgument {
extension Concordium.AccountAddress: ArgumentParser.ExpressibleByArgument {
public init?(argument: String) {
do {
try self.init(base58Check: argument)
Expand All @@ -50,7 +50,7 @@ extension AccountAddress: @retroactive ExpressibleByArgument {
}
}

extension ModuleReference: @retroactive ExpressibleByArgument {
extension Concordium.ModuleReference: ArgumentParser.ExpressibleByArgument {
public init?(argument: String) {
do {
try self.init(Data(hex: argument))
Expand All @@ -60,7 +60,7 @@ extension ModuleReference: @retroactive ExpressibleByArgument {
}
}

extension ReceiveName: @retroactive ExpressibleByArgument {
extension Concordium.ReceiveName: ArgumentParser.ExpressibleByArgument {
public init?(argument: String) {
do {
try self.init(argument)
Expand All @@ -70,7 +70,7 @@ extension ReceiveName: @retroactive ExpressibleByArgument {
}
}

extension CCD: @retroactive ExpressibleByArgument {
extension Concordium.CCD: ArgumentParser.ExpressibleByArgument {
public init?(argument: String) {
do {
try self.init(argument, decimalSeparator: ".")
Expand Down

0 comments on commit 8aa432c

Please sign in to comment.