Skip to content

Commit

Permalink
IOS-3383 Expose signed hashes count into demo view
Browse files Browse the repository at this point in the history
  • Loading branch information
tureck1y committed Apr 7, 2023
1 parent 73be7ac commit deab060
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Example/TangemSdkExample/AppModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AppModel: ObservableObject {
@Published var mnemonicString: String = ""
//Sign
@Published var derivationPath: String = ""
@Published var signHashesCount: String = "15"
//Attestation
@Published var attestationMode: AttestationTask.Mode = .normal
//JSON-RPC
Expand Down Expand Up @@ -251,10 +252,15 @@ extension AppModel {
self.complete(with: "Failed to parse hd path")
return
}

guard let hashesCount = Int(signHashesCount, radix: 10) else {
self.complete(with: "Failed to signed hashes count")
return
}

UIApplication.shared.endEditing()

let hashes = (0..<5).map {_ -> Data in getRandomHash()}
let hashes = (0..<hashesCount).map {_ -> Data in getRandomHash()}

tangemSdk.sign(hashes: hashes,
walletPublicKey: walletPublicKey,
Expand Down
10 changes: 10 additions & 0 deletions Example/TangemSdkExample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ struct ContentView: View {
.textFieldStyle(RoundedBorderTextFieldStyle())
.autocapitalization(.none)
.disableAutocorrection(true)

if case .signHashes = model.method {
Text("Sign hashes count")
.font(.headline)
.bold()

TextField("", text: $model.signHashesCount)
.textFieldStyle(RoundedBorderTextFieldStyle())
.autocapitalization(.none)
}
}
.padding()
.cornerRadius(8)
Expand Down

0 comments on commit deab060

Please sign in to comment.