-
Notifications
You must be signed in to change notification settings - Fork 43
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
IOS-8569 create wallet #4294
Changes from 6 commits
bf11c55
996ece1
0f77bd6
03ea70f
77d5613
28fe86a
a9c786b
6d37a01
23b0956
16c5c6a
d9e400f
4bffb54
ae1d1a5
b350db4
28890c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,9 +62,26 @@ class OnboardingCoordinator: CoordinatorObject { | |
onDismissalAttempt = model.backButtonAction | ||
viewState = .wallet(model) | ||
case .visa: | ||
let visaCardInput: VisaCardActivationInput | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Предлагаю тут подчистить, чтобы просто разворот опционала остался например. Либо передать внутрь VisaOnboardingViewModel и там раскрыть, засоряется координатор There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. вынес в отдельный билдер тот же код, пока без изменений. Пока оставил с фаталами, не хватает выброса ошибки из функции |
||
switch input.cardInput { | ||
case .cardId: | ||
fatalError("Invalid card input for Visa onboarding") | ||
case .cardInfo(let cardInfo): | ||
switch cardInfo.walletData { | ||
case .visa(let activationInput, _): | ||
visaCardInput = activationInput | ||
default: | ||
fatalError("Invalid card input for Visa onboarding") | ||
} | ||
case .userWalletModel(let userWalletModel): | ||
// TODO: IOS-8588 | ||
fatalError("Invalid onboarding input for Visa") | ||
} | ||
let model = VisaOnboardingViewModel( | ||
input: input, | ||
visaActivationManager: VisaActivationManagerFactory().make( | ||
cardInput: visaCardInput, | ||
tangemSdk: TangemSdkDefaultFactory().makeTangemSdk(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. В идеале бы сделать по принципу cardInitializer и других мест по взаимодействию с картой (Common/TangemSdk). TangemSDK по приле не гулет, гуляет сущность, которая работает с картой посредством TangemSDK There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. пока не могу понять как это сделать так, чтобы чисто было, т.к. часть требований ещё уточняется + много кастомных вызовов |
||
urlSessionConfiguration: .default, | ||
logger: AppLog.shared | ||
), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,7 @@ class VisaOnboardingViewModel: ObservableObject { | |
startActivationDelegate: weakify(self, forFunction: VisaOnboardingViewModel.goToNextStep) | ||
) | ||
|
||
lazy var accessCodeSetupViewModel = VisaOnboardingAccessCodeSetupViewModel(delegate: self) | ||
lazy var accessCodeSetupViewModel = VisaOnboardingAccessCodeSetupViewModel(accessCodeValidator: visaActivationManager, delegate: self) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Предлагаю вынести наружу в место сборки ViewModel и конфигурировать там, в итоге получается аккуратнее There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не совсем понял зачем. Сейчас все вью модели создаются как и в других онбордингах лениво и по необходимости. Если обновить - их надо инициализировать при переходах между шагами, сложность такого подхода, что в коде надо будет при переключении шагов инициализировать, как будто бы запутанней будет. А если инициализировать все вложенные модели и на старте онбординга их все внедрять - получается много лишней работы, причем некоторые модели вообще не будут использоваться, но будут тратить время на инициализацию и память. Может не совсем понял твою идею. |
||
|
||
var navigationBarTitle: String { | ||
currentStep.navigationTitle | ||
|
@@ -159,28 +159,6 @@ private extension VisaOnboardingViewModel { | |
userWalletRepository.updateSelection() | ||
coordinator?.closeOnboarding() | ||
} | ||
|
||
// This function will be updated in IOS-8509. Requirements for activation flow was reworked, | ||
// so for now this function is for testing purposes | ||
func startActivation() { | ||
guard activationManagerTask == nil else { | ||
print("Activation task already exists, skipping") | ||
return | ||
} | ||
|
||
guard | ||
case .cardInfo(let cardInfo) = input.cardInput, | ||
case .visa(let accessToken, let refreshToken) = cardInfo.walletData | ||
else { | ||
print("Wrong onboarding input") | ||
return | ||
} | ||
|
||
let authorizationTokens = VisaAuthorizationTokens(accessToken: accessToken, refreshToken: refreshToken) | ||
activationManagerTask = runTask(in: self, isDetached: false) { viewModel in | ||
try await viewModel.visaActivationManager.startActivation(authorizationTokens) | ||
}.eraseToAnyCancellable() | ||
} | ||
} | ||
|
||
extension VisaOnboardingViewModel: UserWalletStorageAgreementRoutable { | ||
|
@@ -230,8 +208,8 @@ extension VisaOnboardingViewModel: VisaOnboardingAccessCodeSetupDelegate { | |
} | ||
|
||
func useSelectedCode(accessCode: String) async throws { | ||
try await Task.sleep(seconds: 5) | ||
throw "Will be implemented later IOS-8509" | ||
try visaActivationManager.saveAccessCode(accessCode: accessCode) | ||
try await visaActivationManager.startActivation() | ||
} | ||
} | ||
|
||
|
@@ -250,10 +228,18 @@ extension VisaOnboardingViewModel { | |
onboardingStepsBuilderFactory: cardMockConfig, | ||
pushNotificationsInteractor: PushNotificationsInteractorMock() | ||
) | ||
guard let cardInput = inputFactory.makeOnboardingInput() else { | ||
fatalError("Failed to generate card input for visa onboarding") | ||
} | ||
|
||
return .init( | ||
input: inputFactory.makeOnboardingInput()!, | ||
input: cardInput, | ||
visaActivationManager: VisaActivationManagerFactory().make( | ||
cardInput: .init( | ||
cardId: cardMock.card.cardId, | ||
cardPublicKey: cardMock.card.cardPublicKey | ||
), | ||
tangemSdk: TangemSdkDefaultFactory().makeTangemSdk(), | ||
urlSessionConfiguration: .default, | ||
logger: AppLog.shared | ||
), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Думаю можно в VisaUtils положить что-то типа isVisa(cardId: ..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
сделал