Skip to content

Commit

Permalink
refactor: make verification depend on protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew54068 committed Sep 29, 2022
1 parent be6ac6e commit 576e564
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Sources/FCL-SDK/AppUtilities/AppUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum AppUtilities {

public static func verifyAccountProof(
appIdentifier: String,
accountProofData: AccountProofSignatureData,
accountProofData: AccountProofVerifiable,
fclCryptoContract: Address?
) async throws -> Bool {
let verifyMessage = WalletUtilities.encodeAccountProof(
Expand Down Expand Up @@ -54,7 +54,7 @@ public enum AppUtilities {

public static func verifyUserSignatures(
message: String,
signatures: [FCLCompositeSignature],
signatures: [CompositeSignatureVerifiable],
fclCryptoContract: Address?
) async throws -> Bool {

Expand Down
14 changes: 10 additions & 4 deletions Sources/FCL-SDK/Models/AccountProofData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@ public struct FCLAccountProofData {

}

public struct AccountProofSignatureData {
public protocol AccountProofVerifiable {
var address: Address { get }
var nonce: String { get }
var signatures: [CompositeSignatureVerifiable] { get }
}

public struct AccountProofSignatureData: AccountProofVerifiable {

let address: Address
let nonce: String
let signatures: [FCLCompositeSignature]
public let address: Address
public let nonce: String
public let signatures: [CompositeSignatureVerifiable]

public init(
address: Address,
Expand Down
8 changes: 7 additions & 1 deletion Sources/FCL-SDK/Models/FCLCompositeSignature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@

import Foundation

public struct FCLCompositeSignature: Decodable {
public protocol CompositeSignatureVerifiable {
var address: String { get }
var keyId: Int { get }
var signature: String { get }
}

public struct FCLCompositeSignature: CompositeSignatureVerifiable, Decodable {

public let fclType: String
public let fclVersion: String
Expand Down

0 comments on commit 576e564

Please sign in to comment.