From b86408fd87c67b5917d44bc348320caa0fa46ee8 Mon Sep 17 00:00:00 2001 From: Elizaveta Semenova Date: Wed, 14 Feb 2024 20:00:00 +0300 Subject: [PATCH 1/2] [ETH-949] Swap state fee bugs --- .../Resources/Base.lproj/Localizable.strings | 2 +- p2p_wallet/Resources/en.lproj/Localizable.strings | 2 +- .../JupiterSwapBusinessLogic+Calculate.swift | 14 +++++++++----- .../BusinessLogic/JupiterSwapBusinessLogic.swift | 1 + .../Swap/SwapSettings/View/SwapSettingsView.swift | 4 ++-- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/p2p_wallet/Resources/Base.lproj/Localizable.strings b/p2p_wallet/Resources/Base.lproj/Localizable.strings index ab8f465ff..2b9743ee4 100644 --- a/p2p_wallet/Resources/Base.lproj/Localizable.strings +++ b/p2p_wallet/Resources/Base.lproj/Localizable.strings @@ -596,7 +596,6 @@ "Share my link" = "Share my link"; "Open details" = "Open details"; "Token 2022 details" = "Token 2022 details"; -"Token 2022 transfer fee" = "Token 2022 transfer fee"; "Calculated by subtracting the token 2022 transfer fee from your balance" = "Calculated by subtracting the token 2022 transfer fee from your balance"; "Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance" = "Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance"; "Update available" = "Update available"; @@ -610,3 +609,4 @@ "Open SOLScan" = "Open SOLScan"; "Terms & Conditions" = "Terms & Conditions"; "Swap fee" = "Swap fee"; +"Token-2022 transfer fee" = "Token-2022 transfer fee"; diff --git a/p2p_wallet/Resources/en.lproj/Localizable.strings b/p2p_wallet/Resources/en.lproj/Localizable.strings index 01f07dd11..6ecfdef8d 100644 --- a/p2p_wallet/Resources/en.lproj/Localizable.strings +++ b/p2p_wallet/Resources/en.lproj/Localizable.strings @@ -584,7 +584,6 @@ "Share my link" = "Share my link"; "Open details" = "Open details"; "Token 2022 details" = "Token 2022 details"; -"Token 2022 transfer fee" = "Token 2022 transfer fee"; "Calculated by subtracting the token 2022 transfer fee from your balance" = "Calculated by subtracting the token 2022 transfer fee from your balance"; "Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance" = "Calculated by subtracting the token 2022 transfer fee and account creation fee from your balance"; "Update available" = "Update available"; @@ -598,3 +597,4 @@ "Open SOLScan" = "Open SOLScan"; "Terms & Conditions" = "Terms & Conditions"; "Swap fee" = "Swap fee"; +"Token-2022 transfer fee" = "Token-2022 transfer fee"; diff --git a/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/Helpers/JupiterSwapBusinessLogic+Calculate.swift b/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/Helpers/JupiterSwapBusinessLogic+Calculate.swift index 43f035f99..c69c81122 100644 --- a/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/Helpers/JupiterSwapBusinessLogic+Calculate.swift +++ b/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/Helpers/JupiterSwapBusinessLogic+Calculate.swift @@ -74,25 +74,29 @@ extension JupiterSwapBusinessLogic { if transferFeeBasisPoints == nil { // Internal function for calculating free basic points @Sendable - func getTransferFeeBasicPointsForToken(mint: String) async throws -> UInt16 { + func getTransferFeeBasicPointsForToken(mint: String) async throws -> UInt16? { let mintState: BufferInfo? = try await services .solanaAPIClient .getAccountInfo(account: mint) - guard let mintState else { return 0 } + guard let mintState else { return nil } let transferFeeConfig = mintState .data .getParsedExtension(ofType: TransferFeeConfigExtensionState.self) - return transferFeeConfig?.newerTransferFee.transferFeeBasisPoints ?? 0 + return transferFeeConfig?.newerTransferFee.transferFeeBasisPoints } async let tokenATransferFee = getTransferFeeBasicPointsForToken(mint: state.fromToken.token.mintAddress) async let tokenBTransferFee = getTransferFeeBasicPointsForToken(mint: state.toToken.token.mintAddress) - let total: UInt16 = try await(tokenATransferFee + tokenBTransferFee) - transferFeeBasisPoints = total + let result = try await(tokenATransferFee, tokenBTransferFee) + if result.0 == nil && result.1 == nil { + transferFeeBasisPoints = nil + } else { + transferFeeBasisPoints = (result.0 ?? 0) + (result.1 ?? 0) + } } return await validateAmounts( diff --git a/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/JupiterSwapBusinessLogic.swift b/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/JupiterSwapBusinessLogic.swift index 76fb2053e..c38f7e03a 100644 --- a/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/JupiterSwapBusinessLogic.swift +++ b/p2p_wallet/Scenes/Main/Swap/State/BusinessLogic/JupiterSwapBusinessLogic.swift @@ -66,6 +66,7 @@ enum JupiterSwapBusinessLogic { $0.routes = [] $0.fromToken = fromToken $0.amountFrom = nil + $0.transferFeeBasisPoints = nil } case let .changeToToken(toToken): return state.modified { diff --git a/p2p_wallet/Scenes/Main/Swap/SwapSettings/View/SwapSettingsView.swift b/p2p_wallet/Scenes/Main/Swap/SwapSettings/View/SwapSettingsView.swift index 5020da91b..42db5292c 100644 --- a/p2p_wallet/Scenes/Main/Swap/SwapSettings/View/SwapSettingsView.swift +++ b/p2p_wallet/Scenes/Main/Swap/SwapSettings/View/SwapSettingsView.swift @@ -80,10 +80,10 @@ struct SwapSettingsView: View { } // Account creation fee - if viewModel.isLoadingOrRouteNotNil { + if viewModel.isLoadingOrRouteNotNil, let fee = viewModel.info.accountCreationFee, fee.amount > 0 { feeRow( title: L10n.accountCreationFee, - fee: viewModel.info.accountCreationFee, + fee: fee, identifier: .accountCreationFee ) } From 8e89b100bc5cf0bbc916d604b095fe5aa3043352 Mon Sep 17 00:00:00 2001 From: Elizaveta Semenova Date: Wed, 14 Feb 2024 20:10:50 +0300 Subject: [PATCH 2/2] [ETH-965] Rename explorer button --- p2p_wallet/Resources/Base.lproj/Localizable.strings | 2 +- p2p_wallet/Resources/en.lproj/Localizable.strings | 2 +- .../Main/TransactionDetailView/TransactionDetailView.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/p2p_wallet/Resources/Base.lproj/Localizable.strings b/p2p_wallet/Resources/Base.lproj/Localizable.strings index 2b9743ee4..3da8bc4be 100644 --- a/p2p_wallet/Resources/Base.lproj/Localizable.strings +++ b/p2p_wallet/Resources/Base.lproj/Localizable.strings @@ -443,7 +443,6 @@ "Mint signature" = "Mint signature"; "Unstake signature" = "Unstake signature"; "Stake signature" = "Stake signature"; -"Explorer" = "Explorer"; "Buy with Moonpay" = "Buy with Moonpay"; "License" = "License"; "Cashout with Moonpay" = "Cashout with Moonpay"; @@ -610,3 +609,4 @@ "Terms & Conditions" = "Terms & Conditions"; "Swap fee" = "Swap fee"; "Token-2022 transfer fee" = "Token-2022 transfer fee"; +"Solscan" = "Solscan"; diff --git a/p2p_wallet/Resources/en.lproj/Localizable.strings b/p2p_wallet/Resources/en.lproj/Localizable.strings index 6ecfdef8d..dcef726ae 100644 --- a/p2p_wallet/Resources/en.lproj/Localizable.strings +++ b/p2p_wallet/Resources/en.lproj/Localizable.strings @@ -159,7 +159,6 @@ "Error with deleting. Try again" = "Error with deleting. Try again"; "Estimated fees" = "Estimated fees"; "Exchanging %@ → %@" = "Exchanging %@ → %@"; -"Explorer" = "Explorer"; "Face ID" = "Face ID"; "Failed to get data" = "Failed to get data"; "Fee" = "Fee"; @@ -598,3 +597,4 @@ "Terms & Conditions" = "Terms & Conditions"; "Swap fee" = "Swap fee"; "Token-2022 transfer fee" = "Token-2022 transfer fee"; +"Solscan" = "Solscan"; diff --git a/p2p_wallet/Scenes/Main/TransactionDetailView/TransactionDetailView.swift b/p2p_wallet/Scenes/Main/TransactionDetailView/TransactionDetailView.swift index 68b8b395f..1a48a8641 100644 --- a/p2p_wallet/Scenes/Main/TransactionDetailView/TransactionDetailView.swift +++ b/p2p_wallet/Scenes/Main/TransactionDetailView/TransactionDetailView.swift @@ -81,7 +81,7 @@ struct DetailTransactionView: View { viewModel.share() } case .explorer: - CircleButton(title: L10n.explorer, image: .explorer) { + CircleButton(title: L10n.solscan, image: .explorer) { viewModel.explore() } }