From 149da5791b1cbe5f0f178e16fe8ac196adc985df Mon Sep 17 00:00:00 2001 From: Andrew Son <24321494+Andoran90@users.noreply.github.com> Date: Thu, 11 Apr 2024 13:31:23 +0500 Subject: [PATCH 01/27] IOS-6433: Add alert for disabled Buy button --- .../Modules/SingleTokenBase/SingleTokenBaseViewModel.swift | 5 +++++ Tangem/Resources/Localizations/de.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/en.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/fr.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/it.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/ru.lproj/Localizable.strings | 1 + .../Localizations/zh-Hant.lproj/Localizable.strings | 1 + 7 files changed, 11 insertions(+) diff --git a/Tangem/Modules/SingleTokenBase/SingleTokenBaseViewModel.swift b/Tangem/Modules/SingleTokenBase/SingleTokenBaseViewModel.swift index 26c5ae2a1c..d5336884dc 100644 --- a/Tangem/Modules/SingleTokenBase/SingleTokenBaseViewModel.swift +++ b/Tangem/Modules/SingleTokenBase/SingleTokenBaseViewModel.swift @@ -361,6 +361,11 @@ extension SingleTokenBaseViewModel { return } + if !exchangeUtility.buyAvailable { + alert = .init(title: Localization.commonWarning, message: Localization.tokenButtonUnavailabilityReasonBuyUnavailable(walletModel.tokenItem.name)) + return + } + tokenRouter.openBuyCryptoIfPossible(walletModel: walletModel) } diff --git a/Tangem/Resources/Localizations/de.lproj/Localizable.strings b/Tangem/Resources/Localizations/de.lproj/Localizable.strings index 4d7227e89f..3107bf3e36 100644 --- a/Tangem/Resources/Localizations/de.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/de.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Balances hidden"; "toast_balances_shown" = "Balances shown"; "toast_undo" = "Undo"; +"token_button_unavailability_reason_buy_unavailable" = "The purchase of the %@ is currently unavailable. But we are working on adding it."; "token_button_unavailability_reason_empty_balance" = "You do not have funds to send. Top up your account to be able to send funds from it."; "token_details_choose_address" = "Choose address"; "token_details_hide_alert_hide" = "Hide"; diff --git a/Tangem/Resources/Localizations/en.lproj/Localizable.strings b/Tangem/Resources/Localizations/en.lproj/Localizable.strings index bb0bacf3f3..8afa932834 100644 --- a/Tangem/Resources/Localizations/en.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/en.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Balances hidden"; "toast_balances_shown" = "Balances shown"; "toast_undo" = "Undo"; +"token_button_unavailability_reason_buy_unavailable" = "The purchase of the %@ is currently unavailable. But we are working on adding it."; "token_button_unavailability_reason_empty_balance" = "You do not have funds to send. Top up your account to be able to send funds from it."; "token_details_choose_address" = "Choose address"; "token_details_hide_alert_hide" = "Hide"; diff --git a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings index f8b3a89d8b..d4d863059a 100644 --- a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Balances hidden"; "toast_balances_shown" = "Balances shown"; "toast_undo" = "Undo"; +"token_button_unavailability_reason_buy_unavailable" = "The purchase of the %@ is currently unavailable. But we are working on adding it."; "token_button_unavailability_reason_empty_balance" = "You do not have funds to send. Top up your account to be able to send funds from it."; "token_details_choose_address" = "Choose address"; "token_details_hide_alert_hide" = "Hide"; diff --git a/Tangem/Resources/Localizations/it.lproj/Localizable.strings b/Tangem/Resources/Localizations/it.lproj/Localizable.strings index c3e1aae4ad..c77170e301 100644 --- a/Tangem/Resources/Localizations/it.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/it.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Balances hidden"; "toast_balances_shown" = "Balances shown"; "toast_undo" = "Undo"; +"token_button_unavailability_reason_buy_unavailable" = "The purchase of the %@ is currently unavailable. But we are working on adding it."; "token_button_unavailability_reason_empty_balance" = "You do not have funds to send. Top up your account to be able to send funds from it."; "token_details_choose_address" = "Choose address"; "token_details_hide_alert_hide" = "Hide"; diff --git a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings index 3b9d7e4e7d..abb1252b4a 100644 --- a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Балансы скрыты"; "toast_balances_shown" = "Балансы показаны"; "toast_undo" = "Отменить"; +"token_button_unavailability_reason_buy_unavailable" = "В данный момент покупка монеты %@ недоступна. Но мы работаем над её добавлением."; "token_button_unavailability_reason_empty_balance" = "У вас нет средств для отправки. Пополните счет, чтобы иметь возможность отправить с него средства."; "token_details_choose_address" = "Выберите адрес"; "token_details_hide_alert_hide" = "Скрыть"; diff --git a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings index d60984068e..cccb0f06c4 100644 --- a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings @@ -532,6 +532,7 @@ "toast_balances_hidden" = "Balances hidden"; "toast_balances_shown" = "Balances shown"; "toast_undo" = "Undo"; +"token_button_unavailability_reason_buy_unavailable" = "The purchase of the %@ is currently unavailable. But we are working on adding it."; "token_button_unavailability_reason_empty_balance" = "You do not have funds to send. Top up your account to be able to send funds from it."; "token_details_choose_address" = "Choose address"; "token_details_hide_alert_hide" = "隱藏"; From 778a15beaa21d12c679d97e52ebf668228a6f11b Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 15:06:27 +0900 Subject: [PATCH 02/27] IOS-6544 Changed fee subtraction logic --- Tangem/Modules/Send/SendAlertBuilder.swift | 4 ++-- Tangem/Modules/Send/SendModel.swift | 6 +++--- Tangem/Modules/Send/SendViewModel.swift | 2 +- Tangem/Resources/Localizations/de.lproj/Localizable.strings | 2 +- Tangem/Resources/Localizations/en.lproj/Localizable.strings | 2 +- Tangem/Resources/Localizations/fr.lproj/Localizable.strings | 2 +- Tangem/Resources/Localizations/it.lproj/Localizable.strings | 2 +- Tangem/Resources/Localizations/ru.lproj/Localizable.strings | 2 +- .../Localizations/zh-Hant.lproj/Localizable.strings | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Tangem/Modules/Send/SendAlertBuilder.swift b/Tangem/Modules/Send/SendAlertBuilder.swift index bf428d9ba5..6d5b8ca801 100644 --- a/Tangem/Modules/Send/SendAlertBuilder.swift +++ b/Tangem/Modules/Send/SendAlertBuilder.swift @@ -20,11 +20,11 @@ enum SendAlertBuilder { ) } - static func makeSubtractFeeFromAmountAlert(_ fee: String, subtractAction: @escaping () -> Void) -> AlertBinder { + static func makeSubtractFeeFromAmountAlert(subtractAction: @escaping () -> Void) -> AlertBinder { let subtractButton = Alert.Button.default(Text(Localization.sendAlertFeeCoverageSubractText), action: subtractAction) return AlertBuilder.makeAlert( title: "", - message: Localization.sendAlertFeeCoverageTitle(fee), + message: Localization.sendAlertFeeCoverageTitle, primaryButton: subtractButton, secondaryButton: .cancel() ) diff --git a/Tangem/Modules/Send/SendModel.swift b/Tangem/Modules/Send/SendModel.swift index f3c5aaec36..2573b3171d 100644 --- a/Tangem/Modules/Send/SendModel.swift +++ b/Tangem/Modules/Send/SendModel.swift @@ -165,16 +165,16 @@ class SendModel { func includeFeeIntoAmount() { guard !_isFeeIncluded.value, - let userInputAmount = userInputAmount.value, + let maxAmount = walletModel.wallet.amounts[walletModel.amountType], let fee = fee.value?.amount, - (userInputAmount - fee).value >= 0 + (maxAmount - fee).value >= 0 else { AppLog.shared.debug("Invalid amount and fee when subtracting") return } _isFeeIncluded.value = true - self.userInputAmount.send(userInputAmount - fee) + userInputAmount.send(maxAmount - fee) } func useMaxAmount() { diff --git a/Tangem/Modules/Send/SendViewModel.swift b/Tangem/Modules/Send/SendViewModel.swift index 685141cfcd..8ff53ef3cb 100644 --- a/Tangem/Modules/Send/SendViewModel.swift +++ b/Tangem/Modules/Send/SendViewModel.swift @@ -434,7 +434,7 @@ final class SendViewModel: ObservableObject { .blockchain: walletModel.tokenItem.blockchain.displayName, ]) - alert = SendAlertBuilder.makeSubtractFeeFromAmountAlert(sendModel.feeText) { [weak self] in + alert = SendAlertBuilder.makeSubtractFeeFromAmountAlert { [weak self] in guard let self else { return } sendModel.includeFeeIntoAmount() fiatCryptoAdapter.setCrypto(sendModel.userInputAmountValue?.value) diff --git a/Tangem/Resources/Localizations/de.lproj/Localizable.strings b/Tangem/Resources/Localizations/de.lproj/Localizable.strings index efd2c34176..80f1c98a86 100644 --- a/Tangem/Resources/Localizations/de.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/de.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "Get your card ready!"; "send_additional_field_already_included" = "Already included in the entered address"; "send_alert_fee_coverage_subract_text" = "Subtract"; -"send_alert_fee_coverage_title" = "Not enough funds to cover the network commission. Subtract the commission %@ from the amount sent?"; +"send_alert_fee_coverage_title" = "Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?"; "send_alert_fee_too_low_text" = "You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?"; "send_alert_transaction_failed_text" = "Reason: %1$s\nCode: %2$s"; "send_alert_transaction_failed_title" = "The transaction is not completed"; diff --git a/Tangem/Resources/Localizations/en.lproj/Localizable.strings b/Tangem/Resources/Localizations/en.lproj/Localizable.strings index bf1aa26a8f..53dfc4a84f 100644 --- a/Tangem/Resources/Localizations/en.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/en.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "Get your card ready!"; "send_additional_field_already_included" = "Already included in the entered address"; "send_alert_fee_coverage_subract_text" = "Subtract"; -"send_alert_fee_coverage_title" = "Not enough funds to cover the network commission. Subtract the commission %@ from the amount sent?"; +"send_alert_fee_coverage_title" = "Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?"; "send_alert_fee_too_low_text" = "You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?"; "send_alert_transaction_failed_text" = "Reason: %1$s\nCode: %2$s"; "send_alert_transaction_failed_title" = "The transaction is not completed"; diff --git a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings index 280d7660cb..c87a7ec66c 100644 --- a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "Get your card ready!"; "send_additional_field_already_included" = "Already included in the entered address"; "send_alert_fee_coverage_subract_text" = "Subtract"; -"send_alert_fee_coverage_title" = "Not enough funds to cover the network commission. Subtract the commission %@ from the amount sent?"; +"send_alert_fee_coverage_title" = "Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?"; "send_alert_fee_too_low_text" = "You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?"; "send_alert_transaction_failed_text" = "Reason: %1$s\nCode: %2$s"; "send_alert_transaction_failed_title" = "The transaction is not completed"; diff --git a/Tangem/Resources/Localizations/it.lproj/Localizable.strings b/Tangem/Resources/Localizations/it.lproj/Localizable.strings index 9885c6b807..581561627c 100644 --- a/Tangem/Resources/Localizations/it.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/it.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "Get your card ready!"; "send_additional_field_already_included" = "Already included in the entered address"; "send_alert_fee_coverage_subract_text" = "Subtract"; -"send_alert_fee_coverage_title" = "Not enough funds to cover the network commission. Subtract the commission %@ from the amount sent?"; +"send_alert_fee_coverage_title" = "Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?"; "send_alert_fee_too_low_text" = "You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?"; "send_alert_transaction_failed_text" = "Reason: %1$s\nCode: %2$s"; "send_alert_transaction_failed_title" = "The transaction is not completed"; diff --git a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings index 410127d32f..a48e7eedbc 100644 --- a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "Приготовьте свою карту"; "send_additional_field_already_included" = "Уже содержится в введенном адресе"; "send_alert_fee_coverage_subract_text" = "Вычесть"; -"send_alert_fee_coverage_title" = "Недостаточно средств для покрытия комиссии сети. Вычесть комиссию %@ из отправляемой суммы?"; +"send_alert_fee_coverage_title" = "Недостаточно средств для покрытия комиссии сети. Вычесть недостающую сумму для покрытия комиссии из отправляемой суммы?"; "send_alert_fee_too_low_text" = "Вы указали комиссию ниже рекомендуемой, это может привести к задержке исполнения вашей транзакции. Продолжить?"; "send_alert_transaction_failed_text" = "Причина: %1$s\nКод: %2$s"; "send_alert_transaction_failed_title" = "Транзакция не выполнена"; diff --git a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings index 8e1520940a..243f1ea43f 100644 --- a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings @@ -419,7 +419,7 @@ "scan_card_settings_title" = "準備好您的卡!"; "send_additional_field_already_included" = "Already included in the entered address"; "send_alert_fee_coverage_subract_text" = "Subtract"; -"send_alert_fee_coverage_title" = "Not enough funds to cover the network commission. Subtract the commission %@ from the amount sent?"; +"send_alert_fee_coverage_title" = "Not enough funds to cover the network fee. Do you want to subtract the amount required to cover the fee?"; "send_alert_fee_too_low_text" = "You specified a commission below the recommended amount, which could cause a delay in your transaction. Continue?"; "send_alert_transaction_failed_text" = "Reason: %1$s\nCode: %2$s"; "send_alert_transaction_failed_title" = "The transaction is not completed"; From 653b57f1b64fc40688f91fa818000ef2278e9fc3 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 15:48:02 +0900 Subject: [PATCH 03/27] IOS-6543 Using feeTokenItem for currency display --- Tangem/Modules/Send/Fee/SendFeeViewModel.swift | 3 ++- Tangem/Modules/Send/SendSummarySectionViewModelFactory.swift | 4 ++-- Tangem/Modules/Send/SendViewModel.swift | 4 ++-- Tangem/Modules/Send/SendWalletInfo.swift | 2 +- Tangem/Modules/Send/Summary/SendSummaryViewModel.swift | 5 +++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Tangem/Modules/Send/Fee/SendFeeViewModel.swift b/Tangem/Modules/Send/Fee/SendFeeViewModel.swift index 31a97da379..ca02105e0d 100644 --- a/Tangem/Modules/Send/Fee/SendFeeViewModel.swift +++ b/Tangem/Modules/Send/Fee/SendFeeViewModel.swift @@ -138,7 +138,8 @@ class SendFeeViewModel: ObservableObject { .map { (self, customFee) -> String? in guard let customFee, - let fiatFee = self.balanceConverter.convertToFiat(value: customFee.amount.value, from: self.walletInfo.feeCurrencyId) + let feeCurrencyId = self.walletInfo.feeCurrencyId, + let fiatFee = self.balanceConverter.convertToFiat(value: customFee.amount.value, from: feeCurrencyId) else { return nil } diff --git a/Tangem/Modules/Send/SendSummarySectionViewModelFactory.swift b/Tangem/Modules/Send/SendSummarySectionViewModelFactory.swift index 513f8a99be..9c11975398 100644 --- a/Tangem/Modules/Send/SendSummarySectionViewModelFactory.swift +++ b/Tangem/Modules/Send/SendSummarySectionViewModelFactory.swift @@ -11,7 +11,7 @@ import BlockchainSdk struct SendSummarySectionViewModelFactory { private let feeCurrencySymbol: String - private let feeCurrencyId: String + private let feeCurrencyId: String? private let isFeeApproximate: Bool private let currencyId: String? private let tokenIconInfo: TokenIconInfo @@ -23,7 +23,7 @@ struct SendSummarySectionViewModelFactory { ) } - init(feeCurrencySymbol: String, feeCurrencyId: String, isFeeApproximate: Bool, currencyId: String?, tokenIconInfo: TokenIconInfo) { + init(feeCurrencySymbol: String, feeCurrencyId: String?, isFeeApproximate: Bool, currencyId: String?, tokenIconInfo: TokenIconInfo) { self.feeCurrencySymbol = feeCurrencySymbol self.feeCurrencyId = feeCurrencyId self.isFeeApproximate = isFeeApproximate diff --git a/Tangem/Modules/Send/SendViewModel.swift b/Tangem/Modules/Send/SendViewModel.swift index 685141cfcd..91c78708c0 100644 --- a/Tangem/Modules/Send/SendViewModel.swift +++ b/Tangem/Modules/Send/SendViewModel.swift @@ -161,8 +161,8 @@ final class SendViewModel: ObservableObject { balance: Localization.sendWalletBalanceFormat(walletModel.balance, walletModel.fiatBalance), blockchain: walletModel.blockchainNetwork.blockchain, currencyId: walletModel.tokenItem.currencyId, - feeCurrencySymbol: walletModel.tokenItem.blockchain.currencySymbol, - feeCurrencyId: walletModel.tokenItem.blockchain.currencyId, + feeCurrencySymbol: walletModel.feeTokenItem.currencySymbol, + feeCurrencyId: walletModel.feeTokenItem.currencyId, isFeeApproximate: walletModel.tokenItem.blockchain.isFeeApproximate(for: walletModel.amountType), tokenIconInfo: tokenIconInfo, cryptoIconURL: cryptoIconURL, diff --git a/Tangem/Modules/Send/SendWalletInfo.swift b/Tangem/Modules/Send/SendWalletInfo.swift index 4271ed18ca..59252a720c 100644 --- a/Tangem/Modules/Send/SendWalletInfo.swift +++ b/Tangem/Modules/Send/SendWalletInfo.swift @@ -17,7 +17,7 @@ struct SendWalletInfo { let blockchain: Blockchain let currencyId: String? let feeCurrencySymbol: String - let feeCurrencyId: String + let feeCurrencyId: String? let isFeeApproximate: Bool let tokenIconInfo: TokenIconInfo let cryptoIconURL: URL? diff --git a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift index 680f98c4d6..58489cd03c 100644 --- a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift +++ b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift @@ -223,14 +223,15 @@ class SendSummaryViewModel: ObservableObject { guard let amount, let fee, - let amountCurrencyId = walletInfo.currencyId + let amountCurrencyId = walletInfo.currencyId, + let feeCurrencyId = walletInfo.feeCurrencyId else { return nil } let converter = BalanceConverter() let amountInFiat = converter.convertToFiat(value: amount.value, from: amountCurrencyId) - let feeInFiat = converter.convertToFiat(value: fee.amount.value, from: walletInfo.feeCurrencyId) + let feeInFiat = converter.convertToFiat(value: fee.amount.value, from: feeCurrencyId) let totalInFiat: Decimal? if let amountInFiat, let feeInFiat { From 45598ddc552699f4c172ee27a66d9a9dab1d426e Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 15:55:59 +0900 Subject: [PATCH 04/27] IOS-6544 Refactoring --- Tangem/Modules/Send/SendAlertBuilder.swift | 2 +- Tangem/Modules/Send/SendModel.swift | 2 +- Tangem/Modules/Send/SendViewModel.swift | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Tangem/Modules/Send/SendAlertBuilder.swift b/Tangem/Modules/Send/SendAlertBuilder.swift index 6d5b8ca801..5e5692675e 100644 --- a/Tangem/Modules/Send/SendAlertBuilder.swift +++ b/Tangem/Modules/Send/SendAlertBuilder.swift @@ -20,7 +20,7 @@ enum SendAlertBuilder { ) } - static func makeSubtractFeeFromAmountAlert(subtractAction: @escaping () -> Void) -> AlertBinder { + static func makeSubtractFeeFromMaxAmountAlert(subtractAction: @escaping () -> Void) -> AlertBinder { let subtractButton = Alert.Button.default(Text(Localization.sendAlertFeeCoverageSubractText), action: subtractAction) return AlertBuilder.makeAlert( title: "", diff --git a/Tangem/Modules/Send/SendModel.swift b/Tangem/Modules/Send/SendModel.swift index 2573b3171d..64c8c6f205 100644 --- a/Tangem/Modules/Send/SendModel.swift +++ b/Tangem/Modules/Send/SendModel.swift @@ -162,7 +162,7 @@ class SendModel { } } - func includeFeeIntoAmount() { + func subtractFeeFromMaxAmount() { guard !_isFeeIncluded.value, let maxAmount = walletModel.wallet.amounts[walletModel.amountType], diff --git a/Tangem/Modules/Send/SendViewModel.swift b/Tangem/Modules/Send/SendViewModel.swift index 8ff53ef3cb..0b26c20428 100644 --- a/Tangem/Modules/Send/SendViewModel.swift +++ b/Tangem/Modules/Send/SendViewModel.swift @@ -434,9 +434,9 @@ final class SendViewModel: ObservableObject { .blockchain: walletModel.tokenItem.blockchain.displayName, ]) - alert = SendAlertBuilder.makeSubtractFeeFromAmountAlert { [weak self] in + alert = SendAlertBuilder.makeSubtractFeeFromMaxAmountAlert { [weak self] in guard let self else { return } - sendModel.includeFeeIntoAmount() + sendModel.subtractFeeFromMaxAmount() fiatCryptoAdapter.setCrypto(sendModel.userInputAmountValue?.value) openStep(step, stepAnimation: stepAnimation, updateFee: false) From 99cbccfdea18520632e1f83966151c516703b489 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 17:07:31 +0900 Subject: [PATCH 05/27] IOS-6552 Limit hidden text field to one line for memo --- .../Send/Destination/SendDestinationTextView.swift | 7 +++++-- .../Destination/SendDestinationTextViewModel.swift | 11 +++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Tangem/Modules/Send/Destination/SendDestinationTextView.swift b/Tangem/Modules/Send/Destination/SendDestinationTextView.swift index c7ae8fb34a..da586097ac 100644 --- a/Tangem/Modules/Send/Destination/SendDestinationTextView.swift +++ b/Tangem/Modules/Send/Destination/SendDestinationTextView.swift @@ -101,16 +101,19 @@ struct SendDestinationTextView: View { Group { clearIcon - if #available(iOS 16, *) { + if #available(iOS 16, *), viewModel.allowMultilineText { TextField("", text: .constant("Two\nLines"), axis: .vertical) .style(inputFieldFont, color: .black) + } else { + TextField("", text: .constant("One Line")) + .style(inputFieldFont, color: .black) } } .opacity(0) HStack(spacing: 12) { Group { - if #available(iOS 16, *) { + if #available(iOS 16, *), viewModel.allowMultilineText { TextField(viewModel.placeholder, text: $viewModel.input, axis: .vertical) .lineLimit(5, reservesSpace: false) } else { diff --git a/Tangem/Modules/Send/Destination/SendDestinationTextViewModel.swift b/Tangem/Modules/Send/Destination/SendDestinationTextViewModel.swift index f61aaeb6cf..46408e470d 100644 --- a/Tangem/Modules/Send/Destination/SendDestinationTextViewModel.swift +++ b/Tangem/Modules/Send/Destination/SendDestinationTextViewModel.swift @@ -11,6 +11,7 @@ import SwiftUI import Combine class SendDestinationTextViewModel: ObservableObject, Identifiable { + let allowMultilineText: Bool let name: String let showAddressIcon: Bool let description: String @@ -40,6 +41,7 @@ class SendDestinationTextViewModel: ObservableObject, Identifiable { didEnterDestination: @escaping (String) -> Void, didPasteDestination: @escaping (String) -> Void ) { + allowMultilineText = style.allowMultilineText name = style.name showAddressIcon = style.showAddressIcon description = style.description @@ -152,6 +154,15 @@ extension SendDestinationTextViewModel { } private extension SendDestinationTextViewModel.Style { + var allowMultilineText: Bool { + switch self { + case .address: + return true + case .additionalField: + return false + } + } + var name: String { switch self { case .address: From d11875c61874094779d4cfe04b1d09ffbd5d7ea0 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 19:49:16 +0900 Subject: [PATCH 06/27] IOS-6557 Added a way to override demo card list --- Tangem/App/Services/Common/AppSettings.swift | 3 +++ Tangem/App/Utilities/DemoUtil.swift | 7 ++++++- Tangem/Common/Storage/StorageType.swift | 1 + .../EnvironmentSetup/EnvironmentSetupView.swift | 17 +++++++++++++++++ .../EnvironmentSetupViewModel.swift | 13 +++++++++++++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/Tangem/App/Services/Common/AppSettings.swift b/Tangem/App/Services/Common/AppSettings.swift index b11c57b9be..ed457b39e9 100644 --- a/Tangem/App/Services/Common/AppSettings.swift +++ b/Tangem/App/Services/Common/AppSettings.swift @@ -72,6 +72,9 @@ class AppSettings { @AppStorageCompat(StorageType.userDidTapSendScreenSummary) var userDidTapSendScreenSummary: Bool = false + @AppStorageCompat(StorageType.forcedDemoCardId) + var forcedDemoCardId: String? = nil + static let shared: AppSettings = .init() private init() {} diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index 37ebefe2cb..6de5cff735 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -11,7 +11,12 @@ import BlockchainSdk struct DemoUtil { func isDemoCard(cardId: String) -> Bool { - demoCardIds.contains(cardId) + if let forcedDemoCardId = AppSettings.shared.forcedDemoCardId, + cardId == forcedDemoCardId { + return true + } + + return demoCardIds.contains(cardId) } func getDemoBlockchains(isTestnet: Bool) -> [String] { diff --git a/Tangem/Common/Storage/StorageType.swift b/Tangem/Common/Storage/StorageType.swift index dbf050e38a..700d069b64 100644 --- a/Tangem/Common/Storage/StorageType.swift +++ b/Tangem/Common/Storage/StorageType.swift @@ -37,4 +37,5 @@ enum StorageType: String { case mainPromotionDismissed = "main_promotion_dismissed" case tokenPromotionDismissed = "token_promotion_dismissed" case userDidTapSendScreenSummary = "user_did_tap_send_screen_summary" + case forcedDemoCardId = "forced_demo_card_id" } diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift index ae67a05160..8af8c3bf69 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift @@ -38,6 +38,8 @@ struct EnvironmentSetupView: View { DefaultHeaderView("Feature toggles") } + demoCardIdControls + promotionProgramControls } .interContentPadding(8) @@ -47,6 +49,21 @@ struct EnvironmentSetupView: View { .alert(item: $viewModel.alert) { $0.alert } } + private var demoCardIdControls: some View { + VStack(spacing: 10) { + Text("Demo card ID") + + TextField("Demo card ID", text: viewModel.forcedDemoCardIdValue().asBinding) + .padding() + .border(.gray, width: 1) + + Text("Note that a restart is required for the override to take effect. Only certain blockchains that have demo balances are considered to have their functionality affected [\(DemoUtil().getDemoBlockchains(isTestnet: false).joined(separator: ", "))]") + .font(.footnote) + + Text("*Warning*: when demo override is imposed on a regular card it still has all the amounts in the respective blockchain wallets and it is still possible to spend these money even though the displayed amount might be different") + } + } + private var promotionProgramControls: some View { VStack(spacing: 30) { Text("PROMOTION PROGRAM") diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift index 18d46de6ba..25f9f2f059 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift @@ -118,6 +118,19 @@ final class EnvironmentSetupViewModel: ObservableObject { updateAwardedPromotionNames() } + func forcedDemoCardIdValue() -> BindingValue { + BindingValue( + root: self, + default: "", + get: { _ in + AppSettings.shared.forcedDemoCardId ?? "" + }, + set: { root, newValue in + AppSettings.shared.forcedDemoCardId = newValue.isEmpty ? nil : newValue + } + ) + } + func copyCurrentPromoCode() { guard let promoCode = promotionService.promoCode else { return } From a7a40383fe55d9d5ae863572c132f9b49e2e0b5f Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 20:11:40 +0900 Subject: [PATCH 07/27] IOS-6557 Refactoring --- Tangem/App/Services/Common/AppSettings.swift | 2 +- Tangem/App/Utilities/DemoUtil.swift | 3 +-- Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift | 5 +++-- .../Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tangem/App/Services/Common/AppSettings.swift b/Tangem/App/Services/Common/AppSettings.swift index ed457b39e9..cea3b38cda 100644 --- a/Tangem/App/Services/Common/AppSettings.swift +++ b/Tangem/App/Services/Common/AppSettings.swift @@ -73,7 +73,7 @@ class AppSettings { var userDidTapSendScreenSummary: Bool = false @AppStorageCompat(StorageType.forcedDemoCardId) - var forcedDemoCardId: String? = nil + var forcedDemoCardId: String = "" static let shared: AppSettings = .init() diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index 6de5cff735..c632a74b37 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -11,8 +11,7 @@ import BlockchainSdk struct DemoUtil { func isDemoCard(cardId: String) -> Bool { - if let forcedDemoCardId = AppSettings.shared.forcedDemoCardId, - cardId == forcedDemoCardId { + if cardId == AppSettings.shared.forcedDemoCardId { return true } diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift index 8af8c3bf69..3a9510cea6 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift @@ -59,8 +59,9 @@ struct EnvironmentSetupView: View { Text("Note that a restart is required for the override to take effect. Only certain blockchains that have demo balances are considered to have their functionality affected [\(DemoUtil().getDemoBlockchains(isTestnet: false).joined(separator: ", "))]") .font(.footnote) - - Text("*Warning*: when demo override is imposed on a regular card it still has all the amounts in the respective blockchain wallets and it is still possible to spend these money even though the displayed amount might be different") + + Text("**Warning**: when demo override is imposed on a regular card it still has all the amounts in the respective blockchain wallets and it is still possible to spend these money even though the displayed amount might be different") + .font(.footnote) } } diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift index 25f9f2f059..6129fa65e2 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift @@ -123,10 +123,10 @@ final class EnvironmentSetupViewModel: ObservableObject { root: self, default: "", get: { _ in - AppSettings.shared.forcedDemoCardId ?? "" + AppSettings.shared.forcedDemoCardId }, set: { root, newValue in - AppSettings.shared.forcedDemoCardId = newValue.isEmpty ? nil : newValue + AppSettings.shared.forcedDemoCardId = newValue } ) } From 1af58e38b2c8930d574f35b3ba74bbc29f721e24 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Fri, 12 Apr 2024 20:32:40 +0900 Subject: [PATCH 08/27] IOS-6555 Check if fee can be subtracted --- Tangem/Modules/Send/SendModel.swift | 8 ++++++-- Tangem/Modules/Send/SendViewModel.swift | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Tangem/Modules/Send/SendModel.swift b/Tangem/Modules/Send/SendModel.swift index f3c5aaec36..20ebc0c94e 100644 --- a/Tangem/Modules/Send/SendModel.swift +++ b/Tangem/Modules/Send/SendModel.swift @@ -58,10 +58,12 @@ class SendModel { validatedAmount.value } - var totalExceedsBalance: Bool { + var shouldSubtractFee: Bool { guard let validatedAmount = validatedAmount.value, - let fee = fee.value + let fee = fee.value, + fee.amount.type == validatedAmount.type, + validatedAmount >= fee.amount else { return false } @@ -295,6 +297,8 @@ class SendModel { do { #warning("TODO: Use await validation") + try walletModel.transactionValidator.validateTotal(amount: validatedAmount, fee: fee.amount) + let transaction = try walletModel.transactionCreator.createTransaction( amount: validatedAmount, fee: fee, diff --git a/Tangem/Modules/Send/SendViewModel.swift b/Tangem/Modules/Send/SendViewModel.swift index 9351bb04d8..d239d81901 100644 --- a/Tangem/Modules/Send/SendViewModel.swift +++ b/Tangem/Modules/Send/SendViewModel.swift @@ -442,7 +442,7 @@ final class SendViewModel: ObservableObject { } private func showSummaryStepAlertIfNeeded(_ step: SendStep, stepAnimation: SendView.StepAnimation, checkCustomFee: Bool) -> Bool { - if sendModel.totalExceedsBalance { + if sendModel.shouldSubtractFee { Analytics.log(event: .sendNoticeNotEnoughFee, params: [ .token: walletModel.tokenItem.currencySymbol, .blockchain: walletModel.tokenItem.blockchain.displayName, From b3dd79d1c4ad081442191eba282e943a7a370b2b Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 11:57:13 +0900 Subject: [PATCH 09/27] IOS-6558 Added a footer --- .../Send/Fee/CustomFeeService/CustomBitcoinFeeService.swift | 2 +- Tangem/Resources/Localizations/de.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/en.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/fr.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/it.lproj/Localizable.strings | 1 + Tangem/Resources/Localizations/ru.lproj/Localizable.strings | 1 + .../Resources/Localizations/zh-Hant.lproj/Localizable.strings | 1 + 7 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Tangem/Modules/Send/Fee/CustomFeeService/CustomBitcoinFeeService.swift b/Tangem/Modules/Send/Fee/CustomFeeService/CustomBitcoinFeeService.swift index ffb15d262b..db2452a072 100644 --- a/Tangem/Modules/Send/Fee/CustomFeeService/CustomBitcoinFeeService.swift +++ b/Tangem/Modules/Send/Fee/CustomFeeService/CustomBitcoinFeeService.swift @@ -112,7 +112,7 @@ extension CustomBitcoinFeeService: CustomFeeService { fieldSuffix: nil, fractionDigits: 0, amountAlternativePublisher: .just(output: nil), - footer: nil + footer: Localization.sendSatoshiPerByteText ) { [weak self] decimalValue in let intValue: Int? if let roundedValue = decimalValue?.rounded() { diff --git a/Tangem/Resources/Localizations/de.lproj/Localizable.strings b/Tangem/Resources/Localizations/de.lproj/Localizable.strings index b0d994beb6..d09e813cc1 100644 --- a/Tangem/Resources/Localizations/de.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/de.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Send to"; "send_recipient_memo_footer" = "A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds"; "send_recipient_wallets_title" = "My wallets"; +"send_satoshi_per_byte_text" = "The fee for a Bitcoin transaction is measured by the number of the smallest Bitcoin unit (Satoshi) per byte of data. The higher this number, the faster the transaction will be processed."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Sending..."; "send_summary_tap_hint" = "Tap any field to change it"; diff --git a/Tangem/Resources/Localizations/en.lproj/Localizable.strings b/Tangem/Resources/Localizations/en.lproj/Localizable.strings index 0a66cd48f5..36a6396c00 100644 --- a/Tangem/Resources/Localizations/en.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/en.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Send to"; "send_recipient_memo_footer" = "A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds"; "send_recipient_wallets_title" = "My wallets"; +"send_satoshi_per_byte_text" = "The fee for a Bitcoin transaction is measured by the number of the smallest Bitcoin unit (Satoshi) per byte of data. The higher this number, the faster the transaction will be processed."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Sending..."; "send_summary_tap_hint" = "Tap any field to change it"; diff --git a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings index 8d03341817..27dd46067d 100644 --- a/Tangem/Resources/Localizations/fr.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/fr.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Send to"; "send_recipient_memo_footer" = "A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds"; "send_recipient_wallets_title" = "My wallets"; +"send_satoshi_per_byte_text" = "The fee for a Bitcoin transaction is measured by the number of the smallest Bitcoin unit (Satoshi) per byte of data. The higher this number, the faster the transaction will be processed."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Sending..."; "send_summary_tap_hint" = "Tap any field to change it"; diff --git a/Tangem/Resources/Localizations/it.lproj/Localizable.strings b/Tangem/Resources/Localizations/it.lproj/Localizable.strings index b17d0d8a32..a50649936f 100644 --- a/Tangem/Resources/Localizations/it.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/it.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Send to"; "send_recipient_memo_footer" = "A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds"; "send_recipient_wallets_title" = "My wallets"; +"send_satoshi_per_byte_text" = "The fee for a Bitcoin transaction is measured by the number of the smallest Bitcoin unit (Satoshi) per byte of data. The higher this number, the faster the transaction will be processed."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Sending..."; "send_summary_tap_hint" = "Tap any field to change it"; diff --git a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings index fc1dc50030..922a653302 100644 --- a/Tangem/Resources/Localizations/ru.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/ru.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Отправить"; "send_recipient_memo_footer" = "Мемо/ Код назначения - это код, разделяющий транзакции к общему получателю в сети криптовалют. Внимание: отсутствие мемо может привести к потере средств."; "send_recipient_wallets_title" = "Мои кошельки"; +"send_satoshi_per_byte_text" = "Это способ измерения комиссии за отправку биткоин-транзакции. Он указывает на количество самой маленькой единицы биткоина (сатоши) за каждый байт данных в транзакции. Чем выше это число, тем быстрее будет обработана транзакция сетью."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Отправка"; "send_summary_tap_hint" = "Нажмите на любое поле, чтобы изменить его"; diff --git a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings index 7c10ff8e05..caa0363578 100644 --- a/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings +++ b/Tangem/Resources/Localizations/zh-Hant.lproj/Localizable.strings @@ -479,6 +479,7 @@ "send_recipient_label" = "Send to"; "send_recipient_memo_footer" = "A Memo/Destination Tag is a unique ID for differentiating transactions sent to the same recipient on the same network. Caution: Omitting a memo may lead to misplaced funds"; "send_recipient_wallets_title" = "My wallets"; +"send_satoshi_per_byte_text" = "The fee for a Bitcoin transaction is measured by the number of the smallest Bitcoin unit (Satoshi) per byte of data. The higher this number, the faster the transaction will be processed."; "send_satoshi_per_byte_title" = "Satoshi per vbyte"; "send_sending" = "Sending..."; "send_summary_tap_hint" = "Tap any field to change it"; From 1182f8ec87aa1bd559502acb7106eec96846f697 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 12:22:20 +0900 Subject: [PATCH 10/27] IOS-6557 Added 2 new demo cards --- Tangem/App/Utilities/DemoUtil.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index c632a74b37..ee27c85ea7 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -369,6 +369,7 @@ extension DemoUtil { "AC01000000044492", "AC01000000044260", "AC01000000044278", + "AC19000000000064", // Note BTC "AB01000000049864", @@ -420,6 +421,7 @@ extension DemoUtil { "AF04000000012022", "AF04000000012030", "FB04000000000152", + "AF19000000000038", ] } } From 7cde05409038ff7bcb8e3e1b49fdfa973a7c118f Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 12:23:26 +0900 Subject: [PATCH 11/27] IOS-6557 Added 2 new demo cards --- Tangem/App/Utilities/DemoUtil.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index f917db9624..9e059e4a94 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -365,6 +365,7 @@ extension DemoUtil { "AC01000000044492", "AC01000000044260", "AC01000000044278", + "AC19000000000064", // Note BTC "AB01000000049864", @@ -426,6 +427,7 @@ extension DemoUtil { "AF15000001195781", "AF15000001195773", "AF15000001195799", + "AF19000000000038", ] } } From 664d0043ef3343cb656449517a4e47bf40d865d7 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 13:04:02 +0900 Subject: [PATCH 12/27] IOS-6557 Reverted back to optional value --- Tangem/App/Services/Common/AppSettings.swift | 2 +- Tangem/App/Utilities/DemoUtil.swift | 6 +++++- .../EnvironmentSetup/EnvironmentSetupViewModel.swift | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Tangem/App/Services/Common/AppSettings.swift b/Tangem/App/Services/Common/AppSettings.swift index cea3b38cda..ed457b39e9 100644 --- a/Tangem/App/Services/Common/AppSettings.swift +++ b/Tangem/App/Services/Common/AppSettings.swift @@ -73,7 +73,7 @@ class AppSettings { var userDidTapSendScreenSummary: Bool = false @AppStorageCompat(StorageType.forcedDemoCardId) - var forcedDemoCardId: String = "" + var forcedDemoCardId: String? = nil static let shared: AppSettings = .init() diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index 9e059e4a94..46e3ca199f 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -11,7 +11,11 @@ import BlockchainSdk struct DemoUtil { func isDemoCard(cardId: String) -> Bool { - demoCardIds.contains(cardId) + if cardId == AppSettings.shared.forcedDemoCardId { + return true + } + + return demoCardIds.contains(cardId) } func getDemoBlockchains(isTestnet: Bool) -> [String] { diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift index 6129fa65e2..25f9f2f059 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift @@ -123,10 +123,10 @@ final class EnvironmentSetupViewModel: ObservableObject { root: self, default: "", get: { _ in - AppSettings.shared.forcedDemoCardId + AppSettings.shared.forcedDemoCardId ?? "" }, set: { root, newValue in - AppSettings.shared.forcedDemoCardId = newValue + AppSettings.shared.forcedDemoCardId = newValue.isEmpty ? nil : newValue } ) } From 22175ff1fe3bacc5c4b30b587c035d5f16b97a0a Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 13:08:43 +0900 Subject: [PATCH 13/27] IOS-6557 Updated the UI --- .../EnvironmentSetup/EnvironmentSetupView.swift | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift index 3a9510cea6..2dcefd1e3a 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift @@ -52,17 +52,23 @@ struct EnvironmentSetupView: View { private var demoCardIdControls: some View { VStack(spacing: 10) { Text("Demo card ID") + .font(.headline) + .textCase(.uppercase) TextField("Demo card ID", text: viewModel.forcedDemoCardIdValue().asBinding) .padding() .border(.gray, width: 1) - Text("Note that a restart is required for the override to take effect. Only certain blockchains that have demo balances are considered to have their functionality affected [\(DemoUtil().getDemoBlockchains(isTestnet: false).joined(separator: ", "))]") - .font(.footnote) + Text( + """ + Note that a restart is required for the override to take effect. Only certain blockchains that have demo balances are considered to have their functionality affected **[\(DemoUtil().getDemoBlockchains(isTestnet: false).joined(separator: ", "))]** - Text("**Warning**: when demo override is imposed on a regular card it still has all the amounts in the respective blockchain wallets and it is still possible to spend these money even though the displayed amount might be different") - .font(.footnote) + **Warning**: when demo override is imposed on a regular card it still has all the amounts in the respective blockchain wallets and it is still possible to spend these money even though the displayed amount might be different + """ + ) + .font(.footnote) } + .padding(.horizontal) } private var promotionProgramControls: some View { From 955c9513c3255dff4bc02f9b47a15fdce718a704 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 13:21:32 +0900 Subject: [PATCH 14/27] IOS-6557 Refactoring --- .../EnvironmentSetupView.swift | 2 +- .../EnvironmentSetupViewModel.swift | 19 +++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift index 2dcefd1e3a..cc66652658 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift @@ -55,7 +55,7 @@ struct EnvironmentSetupView: View { .font(.headline) .textCase(.uppercase) - TextField("Demo card ID", text: viewModel.forcedDemoCardIdValue().asBinding) + TextField("Demo card ID", text: $viewModel.forcedDemoCardId) .padding() .border(.gray, width: 1) diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift index 25f9f2f059..446345a63d 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift @@ -19,6 +19,9 @@ final class EnvironmentSetupViewModel: ObservableObject { @Published var additionalSettingsViewModels: [DefaultRowViewModel] = [] @Published var alert: AlertBinder? + // Demo + @Published var forcedDemoCardId: String = "" + // Promotion @Published var currentPromoCode: String = "" @Published var finishedPromotionNames: String = "" @@ -116,19 +119,15 @@ final class EnvironmentSetupViewModel: ObservableObject { updateFinishedPromotionNames() updateAwardedPromotionNames() - } - func forcedDemoCardIdValue() -> BindingValue { - BindingValue( - root: self, - default: "", - get: { _ in - AppSettings.shared.forcedDemoCardId ?? "" - }, - set: { root, newValue in + forcedDemoCardId = AppSettings.shared.forcedDemoCardId ?? "" + + $forcedDemoCardId + .removeDuplicates() + .sink { newValue in AppSettings.shared.forcedDemoCardId = newValue.isEmpty ? nil : newValue } - ) + .store(in: &bag) } func copyCurrentPromoCode() { From 9972d0f7a2c6489e03b404bac6ad51ddadaf2012 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 13:23:53 +0900 Subject: [PATCH 15/27] IOS-6557 Tweaked the title --- Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift index cc66652658..de745105d5 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupView.swift @@ -51,7 +51,7 @@ struct EnvironmentSetupView: View { private var demoCardIdControls: some View { VStack(spacing: 10) { - Text("Demo card ID") + Text("Demo card override") .font(.headline) .textCase(.uppercase) From e5d902da7aa89f792d0af0fc56bbfb1a6c1f835c Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 16:27:02 +0900 Subject: [PATCH 16/27] IOS-6579 Tweaked summary notifications --- .../Modules/Send/Summary/SendSummaryView.swift | 8 +++----- .../Send/Summary/SendSummaryViewModel.swift | 18 +++++++----------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/Tangem/Modules/Send/Summary/SendSummaryView.swift b/Tangem/Modules/Send/Summary/SendSummaryView.swift index 68c8a228ee..ff942489fa 100644 --- a/Tangem/Modules/Send/Summary/SendSummaryView.swift +++ b/Tangem/Modules/Send/Summary/SendSummaryView.swift @@ -82,23 +82,21 @@ struct SendSummaryView: View { .transition(SendView.Constants.hintViewTransition) } - if !viewModel.animatingAuxiliaryViewsOnAppear { + if viewModel.showNotifications { ForEach(viewModel.notificationInputs) { input in NotificationView(input: input) .padding(.top, spacing) - .transition(SendView.Constants.auxiliaryViewTransition(for: .summary)) } } } - if let transactionDescription = viewModel.transactionDescription, - viewModel.showTransactionDescription { + if let transactionDescription = viewModel.transactionDescription { Text(transactionDescription) .style(Fonts.Regular.caption1, color: Colors.Text.tertiary) .multilineTextAlignment(.center) .padding(.horizontal, 16) - .transition(.opacity) .padding(.bottom, bottomSpacing + 14) + .visible(viewModel.showTransactionDescription) } } .background(Colors.Background.tertiary.edgesIgnoringSafeArea(.all)) diff --git a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift index 3c4aa0350a..8c73ad298e 100644 --- a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift +++ b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift @@ -57,10 +57,9 @@ class SendSummaryViewModel: ObservableObject { @Published var animatingFeeOnAppear = false @Published var showHint = false @Published var transactionDescription: String? + @Published var showNotifications = true @Published var showTransactionDescription = true - @Published var animatingAuxiliaryViewsOnAppear: Bool = false - var didProperlyDisappear: Bool = true @Published private(set) var notificationInputs: [NotificationViewInput] = [] @@ -95,6 +94,10 @@ class SendSummaryViewModel: ObservableObject { } func setupAnimations(previousStep: SendStep) { + showHint = false + showNotifications = false + showTransactionDescription = false + switch previousStep { case .destination: animatingAmountOnAppear = true @@ -115,23 +118,18 @@ class SendSummaryViewModel: ObservableObject { self.animatingDestinationOnAppear = false self.animatingAmountOnAppear = false self.animatingFeeOnAppear = false + self.showNotifications = !self.notificationInputs.isEmpty + self.showTransactionDescription = self.transactionDescription != nil } Analytics.log(.sendConfirmScreenOpened) // For the sake of simplicity we're assuming that notifications aren't going to be created after the screen has been displayed - showHint = false if notificationInputs.isEmpty, !AppSettings.shared.userDidTapSendScreenSummary { withAnimation(SendView.Constants.defaultAnimation.delay(SendView.Constants.animationDuration * 2)) { self.showHint = true } } - - // Show it with a delay, otherwise it will clash with the keyboard - showTransactionDescription = false - withAnimation(SendView.Constants.defaultAnimation.delay(SendView.Constants.animationDuration * 2)) { - self.showTransactionDescription = true - } } func didTapSummary(for step: SendStep) { @@ -250,5 +248,3 @@ class SendSummaryViewModel: ObservableObject { return Localization.sendSummaryTransactionDescription(totalInFiatFormatted, feeInFiatFormatted) } } - -extension SendSummaryViewModel: AuxiliaryViewAnimatable {} From 4a4a963b9edde73e51f3f82b5997ac4459aaf379 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 16:32:34 +0900 Subject: [PATCH 17/27] IOS-6579 Refactoring --- Tangem/Modules/Send/Summary/SendSummaryViewModel.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift index 8c73ad298e..16f6576ea0 100644 --- a/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift +++ b/Tangem/Modules/Send/Summary/SendSummaryViewModel.swift @@ -56,8 +56,8 @@ class SendSummaryViewModel: ObservableObject { @Published var animatingAmountOnAppear = false @Published var animatingFeeOnAppear = false @Published var showHint = false - @Published var transactionDescription: String? @Published var showNotifications = true + @Published var transactionDescription: String? @Published var showTransactionDescription = true var didProperlyDisappear: Bool = true @@ -94,10 +94,6 @@ class SendSummaryViewModel: ObservableObject { } func setupAnimations(previousStep: SendStep) { - showHint = false - showNotifications = false - showTransactionDescription = false - switch previousStep { case .destination: animatingAmountOnAppear = true @@ -111,6 +107,10 @@ class SendSummaryViewModel: ObservableObject { default: break } + + showHint = false + showNotifications = false + showTransactionDescription = false } func onAppear() { From 1213fdf06ad7c8f5730f4051206ddc698a371197 Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 20:36:42 +0900 Subject: [PATCH 18/27] IOS-6557 Moved test cards to development section --- Tangem/App/Utilities/DemoUtil.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index 46e3ca199f..1f3265743e 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -67,6 +67,8 @@ extension DemoUtil { "AB01000000046704", "AB02000000051000", "AB02000000050911", + "AC19000000000064", + "AF19000000000038", // etc "AC03000000091418", @@ -369,7 +371,6 @@ extension DemoUtil { "AC01000000044492", "AC01000000044260", "AC01000000044278", - "AC19000000000064", // Note BTC "AB01000000049864", @@ -431,7 +432,6 @@ extension DemoUtil { "AF15000001195781", "AF15000001195773", "AF15000001195799", - "AF19000000000038", ] } } From 5cb0061accccc9248c1b33eef3d5f09c1f51133a Mon Sep 17 00:00:00 2001 From: Andrey Chukavin Date: Mon, 15 Apr 2024 21:06:08 +0900 Subject: [PATCH 19/27] IOS-6557 Refactoring --- Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift index 446345a63d..77848c71ff 100644 --- a/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift +++ b/Tangem/Modules/EnvironmentSetup/EnvironmentSetupViewModel.swift @@ -125,7 +125,7 @@ final class EnvironmentSetupViewModel: ObservableObject { $forcedDemoCardId .removeDuplicates() .sink { newValue in - AppSettings.shared.forcedDemoCardId = newValue.isEmpty ? nil : newValue + AppSettings.shared.forcedDemoCardId = newValue.nilIfEmpty } .store(in: &bag) } From b776a055bbc5e31fe43b1d6a08dc554c32fca361 Mon Sep 17 00:00:00 2001 From: Sergey Balashov Date: Mon, 15 Apr 2024 13:25:47 +0100 Subject: [PATCH 20/27] IOS-3497 Update Podfile IOS-3497 Update Podfile.lock IOS-3497 Update Podfile --- Podfile | 2 +- Podfile.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Podfile b/Podfile index 0f33cf7f48..648e43a072 100644 --- a/Podfile +++ b/Podfile @@ -31,7 +31,7 @@ end def blockchain_sdk_pods # 'TangemWalletCore' dependency must be added via SPM - pod 'BlockchainSdk', :git => 'https://github.com/tangem/blockchain-sdk-swift.git', :tag => 'develop-556' + pod 'BlockchainSdk', :git => 'https://github.com/tangem/blockchain-sdk-swift.git', :tag => 'develop-558' #pod 'BlockchainSdk', :path => '../blockchain-sdk-swift' pod 'Solana.Swift', :git => 'https://github.com/tangem/Solana.Swift', :tag => '1.2.0-tangem5' diff --git a/Podfile.lock b/Podfile.lock index 0851227809..bfa0928ee3 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -217,7 +217,7 @@ DEPENDENCIES: - Amplitude - BinanceChain (from `https://github.com/tangem/swiftbinancechain.git`, tag `0.0.11`) - BitcoinCore.swift (from `https://github.com/tangem/bitcoincore.git`, tag `0.0.20`) - - BlockchainSdk (from `https://github.com/tangem/blockchain-sdk-swift.git`, tag `develop-556`) + - BlockchainSdk (from `https://github.com/tangem/blockchain-sdk-swift.git`, tag `develop-558`) - BlockiesSwift (~> 0.1.2) - CombineExt (~> 1.8.0) - Firebase/Analytics @@ -277,7 +277,7 @@ EXTERNAL SOURCES: :tag: 0.0.20 BlockchainSdk: :git: https://github.com/tangem/blockchain-sdk-swift.git - :tag: develop-556 + :tag: develop-558 Solana.Swift: :git: https://github.com/tangem/Solana.Swift :tag: 1.2.0-tangem5 @@ -300,7 +300,7 @@ CHECKOUT OPTIONS: :tag: 0.0.20 BlockchainSdk: :git: https://github.com/tangem/blockchain-sdk-swift.git - :tag: develop-556 + :tag: develop-558 Solana.Swift: :git: https://github.com/tangem/Solana.Swift :tag: 1.2.0-tangem5 @@ -353,6 +353,6 @@ SPEC CHECKSUMS: TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6 WalletConnectSwiftV2: c1c2c2fbd0495860baf71515be1b943f0c5dce0c -PODFILE CHECKSUM: 08d44f4fb3d7c88a5667facba72251720b0531ce +PODFILE CHECKSUM: 8c68d89bef31db2a0c568bb04bf26324a19e122c COCOAPODS: 1.15.2 From 529544c48352dadebd81facf7c06ddb1a1f17789 Mon Sep 17 00:00:00 2001 From: Sergey Balashov Date: Thu, 4 Apr 2024 16:41:35 +0100 Subject: [PATCH 21/27] IOS-3497 Update Ethereum protocols --- .../CommonAllowanceProvider.swift | 8 ++++---- .../WalletConnectEthTransactionBuilder.swift | 14 +++++++------- .../App/ViewModels/WalletModel/WalletModel.swift | 8 ++------ 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Tangem/App/Services/CommonAllowanceProvider/CommonAllowanceProvider.swift b/Tangem/App/Services/CommonAllowanceProvider/CommonAllowanceProvider.swift index 68ec4452ee..04297953d8 100644 --- a/Tangem/App/Services/CommonAllowanceProvider/CommonAllowanceProvider.swift +++ b/Tangem/App/Services/CommonAllowanceProvider/CommonAllowanceProvider.swift @@ -12,7 +12,7 @@ import BlockchainSdk class CommonExpressAllowanceProvider { private var ethereumNetworkProvider: EthereumNetworkProvider? - private var ethereumTransactionProcessor: EthereumTransactionProcessor? + private var ethereumTransactionDataBuilder: EthereumTransactionDataBuilder? private let logger: Logger private var spendersAwaitingApprove = Set() @@ -27,7 +27,7 @@ class CommonExpressAllowanceProvider { extension CommonExpressAllowanceProvider: ExpressAllowanceProvider { func setup(wallet: WalletModel) { ethereumNetworkProvider = wallet.ethereumNetworkProvider - ethereumTransactionProcessor = wallet.ethereumTransactionProcessor + ethereumTransactionDataBuilder = wallet.ethereumTransactionDataBuilder } func didSendApproveTransaction(for spender: String) { @@ -80,10 +80,10 @@ extension CommonExpressAllowanceProvider: ExpressAllowanceProvider { } func makeApproveData(spender: String, amount: Decimal) throws -> Data { - guard let ethereumTransactionProcessor else { + guard let ethereumTransactionDataBuilder else { throw AllowanceProviderError.ethereumTransactionProcessorNotFound } - return ethereumTransactionProcessor.buildForApprove(spender: spender, amount: amount) + return ethereumTransactionDataBuilder.buildForApprove(spender: spender, amount: amount) } } diff --git a/Tangem/App/Services/WalletConnect/Utilities/WalletConnectEthTransactionBuilder.swift b/Tangem/App/Services/WalletConnect/Utilities/WalletConnectEthTransactionBuilder.swift index 899e6cb0dc..f5dfadc25a 100644 --- a/Tangem/App/Services/WalletConnect/Utilities/WalletConnectEthTransactionBuilder.swift +++ b/Tangem/App/Services/WalletConnect/Utilities/WalletConnectEthTransactionBuilder.swift @@ -17,16 +17,16 @@ protocol WalletConnectEthTransactionBuilder { struct CommonWalletConnectEthTransactionBuilder { private let zeroString = "0x0" - private func getGasPrice(for tx: WalletConnectEthTransaction, using gasLoader: EthereumGasLoader) async throws -> Int { + private func getGasPrice(for tx: WalletConnectEthTransaction, using ethereumNetworkProvider: EthereumNetworkProvider) async throws -> Int { if let gasPrice = tx.gasPrice?.hexToInteger { return gasPrice } - let price = try await gasLoader.getGasPrice().async() + let price = try await ethereumNetworkProvider.getGasPrice().async() return Int(price) } - private func getGasLimit(for tx: WalletConnectEthTransaction, with amount: Amount, using gasLoader: EthereumGasLoader) async throws -> Int { + private func getGasLimit(for tx: WalletConnectEthTransaction, with amount: Amount, using ethereumNetworkProvider: EthereumNetworkProvider) async throws -> Int { if let dappGasLimit = tx.gas?.hexToInteger ?? tx.gasLimit?.hexToInteger { return dappGasLimit } @@ -37,7 +37,7 @@ struct CommonWalletConnectEthTransactionBuilder { // to send value from dApp instead of creating it yourself. IOS-4865 let valueString = amount.value.isZero ? zeroString : tx.value - let gasLimitBigInt = try await gasLoader.getGasLimit( + let gasLimitBigInt = try await ethereumNetworkProvider.getGasLimit( to: tx.to, from: tx.from, value: valueString, @@ -49,7 +49,7 @@ struct CommonWalletConnectEthTransactionBuilder { extension CommonWalletConnectEthTransactionBuilder: WalletConnectEthTransactionBuilder { func buildTx(from wcTransaction: WalletConnectEthTransaction, for walletModel: WalletModel) async throws -> Transaction { - guard let gasLoader = walletModel.ethereumGasLoader else { + guard let ethereumNetworkProvider = walletModel.ethereumNetworkProvider else { let error = WalletConnectV2Error.missingGasLoader AppLog.shared.error(error) throw error @@ -66,8 +66,8 @@ extension CommonWalletConnectEthTransactionBuilder: WalletConnectEthTransactionB let valueAmount = Amount(with: blockchain, type: .coin, value: value) async let walletUpdate = walletModel.update(silent: false).async() - async let gasPrice = getGasPrice(for: wcTransaction, using: gasLoader) - async let gasLimit = getGasLimit(for: wcTransaction, with: valueAmount, using: gasLoader) + async let gasPrice = getGasPrice(for: wcTransaction, using: ethereumNetworkProvider) + async let gasLimit = getGasLimit(for: wcTransaction, with: valueAmount, using: ethereumNetworkProvider) let feeValue = try await Decimal(gasLimit) * Decimal(gasPrice) / blockchain.decimalValue let gasAmount = Amount(with: blockchain, value: feeValue) diff --git a/Tangem/App/ViewModels/WalletModel/WalletModel.swift b/Tangem/App/ViewModels/WalletModel/WalletModel.swift index f08276908c..700339c502 100644 --- a/Tangem/App/ViewModels/WalletModel/WalletModel.swift +++ b/Tangem/App/ViewModels/WalletModel/WalletModel.swift @@ -631,10 +631,6 @@ extension WalletModel { walletManager as? BitcoinTransactionFeeCalculator } - var ethereumGasLoader: EthereumGasLoader? { - walletManager as? EthereumGasLoader - } - var ethereumTransactionSigner: EthereumTransactionSigner? { walletManager as? EthereumTransactionSigner } @@ -643,8 +639,8 @@ extension WalletModel { walletManager as? EthereumNetworkProvider } - var ethereumTransactionProcessor: EthereumTransactionProcessor? { - walletManager as? EthereumTransactionProcessor + var ethereumTransactionDataBuilder: EthereumTransactionDataBuilder? { + walletManager as? EthereumTransactionDataBuilder } var signatureCountValidator: SignatureCountValidator? { From 9b14aae783c4c76e3c80a4d8ef9a5b46373a27a8 Mon Sep 17 00:00:00 2001 From: Sergey Balashov Date: Mon, 15 Apr 2024 13:30:58 +0100 Subject: [PATCH 22/27] IOS-3497 Update Package.resolved --- TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved index 335312ae6d..28197ee9d4 100644 --- a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,4 +1,5 @@ { + "originHash" : "b4054eb42ba68d5494e329b1b5ada27b86a35abfe2422c9f838f1be5b357085c", "pins" : [ { "identity" : "anyasyncsequence", @@ -181,5 +182,5 @@ } } ], - "version" : 2 + "version" : 3 } From 63a3b3e8a5b7f6cbe981bc71710d8bede51dbac8 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Mon, 15 Apr 2024 15:42:11 +0300 Subject: [PATCH 23/27] IOS-6582: Stricter verification of token contract addresses for EVM token transfers Signed-off-by: Andrey Fedorov --- .../App/Services/QRCodeParser/QRCodeParser.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Tangem/App/Services/QRCodeParser/QRCodeParser.swift b/Tangem/App/Services/QRCodeParser/QRCodeParser.swift index 7dfcf9e81f..fff21b9231 100644 --- a/Tangem/App/Services/QRCodeParser/QRCodeParser.swift +++ b/Tangem/App/Services/QRCodeParser/QRCodeParser.swift @@ -46,17 +46,19 @@ struct QRCodeParser { case .message, .memo: result.memo = parameterValue.removingPercentEncoding case .address: - // Overrides destination address for token transfers (ERC-681) - guard case .token(let token) = amountType else { continue } - + // Overrides destination address for token transfers (`address` parameter from ERC-681) + // // `address` parameter is used only if the contract address, encoded in the QR, // matches the contract address of the token from `amountType` property. // Otherwise, the scanned string is likely malformed, and we stop the entire parsing routine - if token.contractAddress.caseInsensitiveCompare(result.destination) == .orderedSame { - result.destination = parameterValue - } else { + guard + case .token(let token) = amountType, + token.contractAddress.caseInsensitiveCompare(result.destination) == .orderedSame + else { return nil } + + result.destination = parameterValue case .value, .uint256: // According to ERC-681, the value is specified in the atomic unit (i.e. wei). Converting it to decimals if let valueInSmallestDenomination = Decimal(stringValue: parameterValue) { From 0d28a3939aa7abd332432e710f41160af61b6af3 Mon Sep 17 00:00:00 2001 From: Sergey Balashov Date: Mon, 15 Apr 2024 14:23:27 +0100 Subject: [PATCH 24/27] IOS-3497 Revert "IOS-3497 Update Package.resolved" This reverts commit 9b14aae783c4c76e3c80a4d8ef9a5b46373a27a8. --- TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved index 28197ee9d4..335312ae6d 100644 --- a/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/TangemApp.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,4 @@ { - "originHash" : "b4054eb42ba68d5494e329b1b5ada27b86a35abfe2422c9f838f1be5b357085c", "pins" : [ { "identity" : "anyasyncsequence", @@ -182,5 +181,5 @@ } } ], - "version" : 3 + "version" : 2 } From a9adfc3d02ade39afb0bc78095d17f2e622b83d6 Mon Sep 17 00:00:00 2001 From: Alexander Osokin Date: Mon, 15 Apr 2024 16:06:46 +0100 Subject: [PATCH 25/27] IOS-6416 Add demo cards --- Tangem/App/Utilities/DemoUtil.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index 1f3265743e..fee4c2a2c5 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -69,6 +69,9 @@ extension DemoUtil { "AB02000000050911", "AC19000000000064", "AF19000000000038", + "AB02000000000007", //NOTE ETH + "AC03000000076229", // Wallet 1 + "AF04000000000118", // Wallet 2 // etc "AC03000000091418", From 1f41a9a0b2bded79b1253fe8abb4757b8bea0e51 Mon Sep 17 00:00:00 2001 From: Alexander Osokin Date: Mon, 15 Apr 2024 16:10:04 +0100 Subject: [PATCH 26/27] Disable mantle and manta --- Tangem/App/Models/Config/SupportedBlockchains.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tangem/App/Models/Config/SupportedBlockchains.swift b/Tangem/App/Models/Config/SupportedBlockchains.swift index 6339f5a3cc..a06d216897 100644 --- a/Tangem/App/Models/Config/SupportedBlockchains.swift +++ b/Tangem/App/Models/Config/SupportedBlockchains.swift @@ -58,6 +58,8 @@ struct SupportedBlockchains { /// Blockchains for test. They don't include in supported blockchains by default private func testableBlockchains() -> Set { [ + .mantle(testnet: false), + .manta(testnet: false), ] } @@ -115,12 +117,10 @@ struct SupportedBlockchains { .aurora(testnet: false), .base(testnet: false), .playa3ullGames, - .manta(testnet: false), .zkSync(testnet: false), .moonbeam(testnet: false), .polygonZkEVM(testnet: false), .moonriver(testnet: false), - .mantle(testnet: false), .flare(testnet: false), .taraxa(testnet: false), ] From 55c3b8edd26632d0a2d4218d171902b23d4ce71e Mon Sep 17 00:00:00 2001 From: Alexander Osokin Date: Mon, 15 Apr 2024 16:57:50 +0100 Subject: [PATCH 27/27] IOS-6588 Close Taraxa --- Podfile | 2 +- Podfile.lock | 8 ++++---- Tangem/App/Utilities/DemoUtil.swift | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Podfile b/Podfile index 17530dc4f6..0d1b40361f 100644 --- a/Podfile +++ b/Podfile @@ -31,7 +31,7 @@ end def blockchain_sdk_pods # 'TangemWalletCore' dependency must be added via SPM - pod 'BlockchainSdk', :git => 'https://github.com/tangem/blockchain-sdk-swift.git', :tag => 'develop-548.2' + pod 'BlockchainSdk', :git => 'https://github.com/tangem/blockchain-sdk-swift.git', :tag => 'develop-548.3' #pod 'BlockchainSdk', :path => '../blockchain-sdk-swift' pod 'Solana.Swift', :git => 'https://github.com/tangem/Solana.Swift', :tag => '1.2.0-tangem5' diff --git a/Podfile.lock b/Podfile.lock index 4fbf463d38..3891d39ebd 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -217,7 +217,7 @@ DEPENDENCIES: - Amplitude - BinanceChain (from `https://github.com/tangem/swiftbinancechain.git`, tag `0.0.11`) - BitcoinCore.swift (from `https://github.com/tangem/bitcoincore.git`, tag `0.0.20`) - - BlockchainSdk (from `https://github.com/tangem/blockchain-sdk-swift.git`, tag `develop-548.2`) + - BlockchainSdk (from `https://github.com/tangem/blockchain-sdk-swift.git`, tag `develop-548.3`) - BlockiesSwift (~> 0.1.2) - CombineExt (~> 1.8.0) - Firebase/Analytics @@ -277,7 +277,7 @@ EXTERNAL SOURCES: :tag: 0.0.20 BlockchainSdk: :git: https://github.com/tangem/blockchain-sdk-swift.git - :tag: develop-548.2 + :tag: develop-548.3 Solana.Swift: :git: https://github.com/tangem/Solana.Swift :tag: 1.2.0-tangem5 @@ -300,7 +300,7 @@ CHECKOUT OPTIONS: :tag: 0.0.20 BlockchainSdk: :git: https://github.com/tangem/blockchain-sdk-swift.git - :tag: develop-548.2 + :tag: develop-548.3 Solana.Swift: :git: https://github.com/tangem/Solana.Swift :tag: 1.2.0-tangem5 @@ -353,6 +353,6 @@ SPEC CHECKSUMS: TweetNacl: 3abf4d1d2082b0114e7a67410e300892448951e6 WalletConnectSwiftV2: c1c2c2fbd0495860baf71515be1b943f0c5dce0c -PODFILE CHECKSUM: c8e924526a52a2ad8b54b8e95a123344b931f128 +PODFILE CHECKSUM: 9e208eb9a3d15c6b07e2a1fcd4a967ea20df7b34 COCOAPODS: 1.15.2 diff --git a/Tangem/App/Utilities/DemoUtil.swift b/Tangem/App/Utilities/DemoUtil.swift index fee4c2a2c5..0950f9071e 100644 --- a/Tangem/App/Utilities/DemoUtil.swift +++ b/Tangem/App/Utilities/DemoUtil.swift @@ -69,7 +69,7 @@ extension DemoUtil { "AB02000000050911", "AC19000000000064", "AF19000000000038", - "AB02000000000007", //NOTE ETH + "AB02000000000007", // NOTE ETH "AC03000000076229", // Wallet 1 "AF04000000000118", // Wallet 2