Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOS-8569 create wallet #4294

Merged
merged 15 commits into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 34 additions & 2 deletions TangemVisa/TangemSdk/CardActivationTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,31 @@ private extension CardActivationTask {
}

func createWallet(in session: CardSession, completion: @escaping CompletionHandler) {
// TODO: IOS-8569
if let taskCancellationError {
completion(.failure(taskCancellationError))
return
}

guard let card = session.environment.card else {
completion(.failure(.missingPreflightRead))
return
}

let utils = VisaUtilities(isTestnet: false)
if card.wallets.contains(where: { $0.curve == utils.mandatoryCurve }) {
createOTP(in: session, completion: completion)
return
}

let createWallet = CreateWalletTask(curve: utils.mandatoryCurve)
createWallet.run(in: session) { result in
switch result {
case .success:
self.createOTP(in: session, completion: completion)
case .failure(let error):
completion(.failure(error))
}
}
}

func createOTP(in session: CardSession, completion: @escaping CompletionHandler) {
Expand Down Expand Up @@ -127,7 +151,15 @@ private extension CardActivationTask {
in session: CardSession,
completion: @escaping CompletionHandler
) {
// TODO: IOS-8569
let setAccessCodeCommand = SetUserCodeCommand(accessCode: selectedAccessCode)
setAccessCodeCommand.run(in: session) { result in
switch result {
case .success:
completion(.success(signResponse))
case .failure(let error):
completion(.failure(error))
}
}
}
}

Expand Down
Loading