Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ class SwapProcessingViewModel {
// Convert names its destination via `currencyName`, so the
// same "X of <currency>" reads correctly there too.
return "\(exchangedFiat.nativeAmount.formatted()) of \(currencyName)"
case .sell:
return "\(exchangedFiat.nativeAmount.formatted()) of USDF"
}
}
return "Transaction Complete"
Expand All @@ -45,7 +43,7 @@ class SwapProcessingViewModel {
return "This transaction typically takes about a minute. You may leave the app while it completes"
case .success:
switch swapType {
case .buyWithReserves, .buyWithCurrency, .sell, .convert:
case .buyWithReserves, .buyWithCurrency, .convert:
return "was just added to your Flipcash wallet"
}
case .failed:
Expand All @@ -70,8 +68,6 @@ class SwapProcessingViewModel {
switch swapType {
case .buyWithReserves, .buyWithCurrency:
"Buying \(currencyName)"
case .sell:
"Selling \(currencyName)"
case .convert:
"Converting"
}
Expand All @@ -94,8 +90,7 @@ class SwapProcessingViewModel {

private let swapId: SwapId
private let swapType: SwapType
/// The token being bought — analytics-only; nil on the sell path, where
/// `amount.mint` already names the subject token.
/// The token being bought, or a convert's destination — analytics-only.
private let targetMint: PublicKey?
private let currencyName: String
private let amount: ExchangedFiat
Expand Down Expand Up @@ -191,8 +186,6 @@ class SwapProcessingViewModel {
Analytics.tokenPurchase(method: .purchaseWithReserves, targetMint: targetMint, exchangedFiat: amount, successful: successful)
case .buyWithCurrency:
Analytics.tokenPurchase(method: .purchaseWithCurrency, targetMint: targetMint, exchangedFiat: amount, successful: successful)
case .sell:
Analytics.tokenSell(exchangedFiat: amount, successful: successful)
case .convert:
// A convert always disposes of the source token; record it as a
// sell of the amount that left the wallet.
Expand Down Expand Up @@ -222,7 +215,6 @@ enum SwapError: Error {
nonisolated enum SwapType: CaseIterable {
case buyWithReserves
case buyWithCurrency
case sell
/// Selling one currency straight into another (source → USDF, or source →
/// another launchpad token). Drives the "Converting" copy.
case convert
Expand Down
6 changes: 2 additions & 4 deletions FlipcashTests/SwapProcessingViewModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import FlipcashCore
@MainActor
struct SwapProcessingViewModelTests {

@Test("SwapType exposes the reserves, currency-paid, sell, and convert cases")
@Test("SwapType exposes the reserves, currency-paid, and convert cases")
func swapType_exposesExpectedCases() {
#expect(SwapType.allCases.count == 4)
#expect(SwapType.allCases.count == 3)
#expect(SwapType.allCases.contains(.buyWithReserves))
#expect(SwapType.allCases.contains(.buyWithCurrency))
#expect(SwapType.allCases.contains(.sell))
#expect(SwapType.allCases.contains(.convert))
}

Expand All @@ -33,7 +32,6 @@ struct SwapProcessingViewModelTests {
}
#expect(makeViewModel(.buyWithReserves).navigationTitle == "Buying TestCoin")
#expect(makeViewModel(.buyWithCurrency).navigationTitle == "Buying TestCoin")
#expect(makeViewModel(.sell).navigationTitle == "Selling TestCoin")
// Convert spans two currencies, so the title names neither.
#expect(makeViewModel(.convert).navigationTitle == "Converting")
}
Expand Down