From adb0805e2c3ca9e3f90196a00e1267b0ba185a4d Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 21 Jun 2022 11:03:34 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../tasks/product/CreateProductWalletTask.kt | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/tasks/product/CreateProductWalletTask.kt b/app/src/main/java/com/tangem/tap/domain/tasks/product/CreateProductWalletTask.kt index 06afdcbd3c..982ed86857 100644 --- a/app/src/main/java/com/tangem/tap/domain/tasks/product/CreateProductWalletTask.kt +++ b/app/src/main/java/com/tangem/tap/domain/tasks/product/CreateProductWalletTask.kt @@ -112,31 +112,44 @@ private class CreateWalletTangemWallet : ProductCommandProcessor when (result) { is CompletionResult.Success -> { - val createWalletResponses = result.data.createWalletResponses - when { - card.settings.isBackupAllowed -> { - linkPrimaryCard(createWalletResponses, session, callback) - } - card.settings.isHDWalletAllowed -> { - deriveKeys(createWalletResponses, session, callback) - } - else -> { - callback( - CompletionResult.Success( - CreateProductWalletTaskResponse(card = session.environment.card!!) - ) - ) - } - } + proceedWithCreatedWallets(result.data.createWalletResponses, session, callback) } is CompletionResult.Failure -> callback(CompletionResult.Failure(result.error)) } } } + private fun proceedWithCreatedWallets( + createWalletResponses: List, + session: CardSession, + callback: (result: CompletionResult) -> Unit, + ) { + when { + card.settings.isBackupAllowed -> { + linkPrimaryCard(createWalletResponses, session, callback) + } + card.settings.isHDWalletAllowed -> { + deriveKeys(createWalletResponses, session, callback) + } + else -> { + callback( + CompletionResult.Success( + CreateProductWalletTaskResponse(card = session.environment.card!!) + ) + ) + } + } + } + private fun linkPrimaryCard( createWalletResponse: List, session: CardSession,