Skip to content
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

[ETH-780] Fix share link && history No applause animation for now #1679

Merged
merged 7 commits into from
Feb 8, 2024
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 @@ -80,6 +80,8 @@ public struct HistoryTransaction: Identifiable, Codable {
info = try .wormholeReceive(container.decode(WormholeReceive.self, forKey: .info))
case .tryCreateAccount:
info = .tryCreateAccount
case .referralReward:
info = try .referralReward(container.decode(Transfer.self, forKey: .info))
case .unknown:
info = try .unknown(container.decode(TokenAmount.self, forKey: .info))
}
Expand Down Expand Up @@ -117,6 +119,7 @@ public extension HistoryTransaction {
case wormholeSend = "wormhole_send"
case wormholeReceive = "wormhole_receive"
case tryCreateAccount = "try_create_account"
case referralReward = "referral_reward"
case unknown
}

Expand Down Expand Up @@ -144,6 +147,7 @@ public extension HistoryTransaction {
case wormholeSend(WormholeSend)
case wormholeReceive(WormholeReceive)
case tryCreateAccount
case referralReward(Transfer)
case unknown(TokenAmount)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "8e68404f641300bfd0e37d478683bb275926760c",
"version" : "1.15.2"
"revision" : "e7b77228b34057041374ebef00c0fd7739d71a2b",
"version" : "1.15.3"
}
},
{
Expand Down
4 changes: 4 additions & 0 deletions p2p_wallet/Common/Extensions/String+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ extension String {
static func secretConfig(_ key: String) -> String? {
Bundle.main.infoDictionary?[key] as? String
}

var shortAddress: String {
"\(prefix(6))...\(suffix(6))"
}
}

extension String {
Expand Down
3 changes: 2 additions & 1 deletion p2p_wallet/Resources/Base.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,10 @@
"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";
"Referral program" = "Referral program";
"Hey, let’s swap trendy meme coins with me!" = "Hey, let’s swap trendy meme coins with me!";
"%@ all the time" = "%@ all the time";
"Here’s how do we count your profits for total balance and every single token" = "Here’s how do we count your profits for total balance and every single token";
"Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy." = "Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy.";
"%@%% last 24h" = "%@%% last 24h";
"Result of an investment, trading strategy per 24 hours" = "Result of an investment, trading strategy per 24 hours";
"Referral reward" = "Referral reward";
"Open SOLScan" = "Open SOLScan";
3 changes: 2 additions & 1 deletion p2p_wallet/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,10 @@
"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";
"Referral program" = "Referral program";
"Hey, let’s swap trendy meme coins with me!" = "Hey, let’s swap trendy meme coins with me!";
"%@ all the time" = "%@ all the time";
"Here’s how do we count your profits for total balance and every single token" = "Here’s how do we count your profits for total balance and every single token";
"Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy." = "Based on absolute and relative profitability of each trade. It shows the relative potential %% profits or losses of your trading strategy.";
"%@%% last 24h" = "%@%% last 24h";
"Result of an investment, trading strategy per 24 hours" = "Result of an investment, trading strategy per 24 hours";
"Referral reward" = "Referral reward";
"Open SOLScan" = "Open SOLScan";
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,3 @@ struct AllTimePnLInfoBottomSheet: View {
// )
// ) {}
// }

// MARK: - Helpers

private extension String {
var shortAddress: String {
"\(prefix(6))...\(suffix(6))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ final class CryptoCoordinator: Coordinator<CryptoResult> {
.eraseToAnyPublisher()
case let .shareReferral(link):
let activityVC = UIActivityViewController(
activityItems: ["\(L10n.heyLetSSwapTrendyMemeCoinsWithMe) \(link)"],
activityItems: [link],
applicationActivities: nil
)
navigationController.present(activityVC, animated: true)
Expand All @@ -223,7 +223,7 @@ final class CryptoCoordinator: Coordinator<CryptoResult> {
showPnLInfo()
}())
.eraseToAnyPublisher()

default:
return Just(())
.eraseToAnyPublisher()
Expand Down
8 changes: 0 additions & 8 deletions p2p_wallet/Scenes/Main/Crypto/Container/CryptoViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,3 @@ extension CryptoViewModel {
case accounts
}
}

// MARK: - Helpers

private extension String {
var shortAddress: String {
"\(prefix(6))...\(suffix(6))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ struct RendableListHistoryTransactionItem: RendableListTransactionItem {
case .tryCreateAccount:
return .icon(.planet)

case let .referralReward(data):
return icon(mint: data.token.mint, url: data.token.logoUrl, defaultIcon: .transactionReceive)

case .unknown, .none:
return .icon(.planet)
}
Expand Down Expand Up @@ -125,6 +128,8 @@ struct RendableListHistoryTransactionItem: RendableListTransactionItem {
return "Ethereum network"
case .tryCreateAccount:
return L10n.unknown
case let .referralReward(data):
return L10n.referralReward
case .unknown, .none:
return L10n.unknown
}
Expand All @@ -148,6 +153,8 @@ struct RendableListHistoryTransactionItem: RendableListTransactionItem {
return "Claim"
case .tryCreateAccount:
return ""
case .referralReward:
return date.string(withFormat: "HH:mm")
default:
return "\(L10n.signature): \(RecipientFormatter.shortSignature(signature: trx.signature))"
}
Expand Down Expand Up @@ -240,6 +247,12 @@ struct RendableListHistoryTransactionItem: RendableListTransactionItem {
case .tryCreateAccount:
return (.unchanged, "")

case let .referralReward(data):
return (
.positive,
"+\(data.amount.tokenAmountDouble.tokenAmountFormattedString(symbol: data.token.symbol))"
)

case .none:
return (.unchanged, "")
}
Expand Down Expand Up @@ -293,6 +306,12 @@ struct RendableListHistoryTransactionItem: RendableListTransactionItem {
case .tryCreateAccount:
return ""

case let .referralReward(data):
guard let usdAmount = data.amount.usdAmountDouble else {
return ""
}
return "\(usdAmount.fiatAmountFormattedString())"

case .none:
return ""
}
Expand Down
8 changes: 0 additions & 8 deletions p2p_wallet/Scenes/Main/NewHome/HomeViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,3 @@ extension HomeViewModel {
case wallet
}
}

// MARK: - Helpers

private extension String {
var shortAddress: String {
"\(prefix(4))...\(suffix(4))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class SettingsCoordinator: Coordinator<Void> {
.store(in: &subscriptions)
case let .shareReferral(link):
let activityVC = UIActivityViewController(
activityItems: ["\(L10n.heyLetSSwapTrendyMemeCoinsWithMe) \(link)"],
activityItems: [link],
applicationActivities: nil
)
navigationController.present(activityVC, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class ReferralProgramCoordinator: Coordinator<Void> {
viewModel.openShare
.sink { [weak vc] link in
let activityVC = UIActivityViewController(
activityItems: ["\(L10n.heyLetSSwapTrendyMemeCoinsWithMe) \(link)"],
activityItems: [link],
applicationActivities: nil
)
vc?.present(activityVC, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,3 @@ struct NonStrictTokenConfirmationView: View {
)
) {}
}

// MARK: - Helpers

private extension String {
var shortAddress: String {
"\(prefix(6))...\(suffix(6))"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
}

var title: String {
switch trx.status {
case .success:
return L10n.transactionSucceeded
case .failed:
return L10n.transactionFailed
switch trx.info {
case .referralReward:
return L10n.referralReward
default:
switch trx.status {
case .success:
return L10n.transactionSucceeded
case .failed:
return L10n.transactionFailed
}
}
}

Expand Down Expand Up @@ -87,6 +92,9 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
case .tryCreateAccount:
return .icon(.planet)

case let .referralReward(data):
return icon(mint: data.token.mint, url: data.token.logoUrl, defaultIcon: .transactionReceive)

case .unknown, .none:
return .icon(.planet)
}
Expand Down Expand Up @@ -177,6 +185,9 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
case .tryCreateAccount:
return .unchanged("")

case let .referralReward(data):
return .positive("+\(data.amount.tokenAmountDouble.tokenAmountFormattedString(symbol: data.token.symbol))")

case .none:
return .unchanged("")
}
Expand Down Expand Up @@ -227,6 +238,9 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
case .tryCreateAccount:
return ""

case let .referralReward(data):
return ""

case .none:
return ""
}
Expand Down Expand Up @@ -298,6 +312,19 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
)
case .swap:
break
case let .referralReward(data):
let value: String
if let name = data.account.name {
value = "@\(name)"
} else {
value = data.account.address.shortAddress
}
result.append(
.init(
title: L10n.from,
values: [.init(text: value)]
)
)

default:
result.append(
Expand Down Expand Up @@ -333,7 +360,14 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
return result
}

var actions: [TransactionDetailAction] = [.share, .explorer]
var actions: [TransactionDetailAction] {
switch trx.info {
case .referralReward:
return []
default:
return [.share, .explorer]
}
}

/// Resolve token icon url
private func resolveTokenIconURL(mint: String?, fallbackImageURL: URL?) -> URL? {
Expand All @@ -358,27 +392,29 @@ struct RendableDetailHistoryTransaction: RenderableTransactionDetail {
}
}

var buttonTitle: String {
var bottomActions: [TransactionBottomAction] {
switch trx.info {
case .swap:
switch status {
case let .error(_, error):
if let error, error.isSlippageError {
return L10n.increaseSlippageAndTryAgain
return [.increaseSlippageAndTryAgain]
} else {
return L10n.tryAgain
return [.tryAgain]
}
default:
return L10n.done
return [.done]
}
case .referralReward:
return [.done, .solscan]

default:
return L10n.done
return [.done]
}
}

var url: String? {
"https://explorer.solana.com/tx/\(signature ?? "")"
"https://solscan.io/tx/\(signature ?? "")"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ struct MockedRendableDetailTransaction: RenderableTransactionDetail {
var amountInToken: String
var extra: [TransactionDetailExtraInfo]
var actions: [TransactionDetailAction]
var buttonTitle: String
var bottomActions: [TransactionBottomAction]
var url: String?

init(
Expand All @@ -23,7 +23,7 @@ struct MockedRendableDetailTransaction: RenderableTransactionDetail {
amountInToken: String,
extra: [TransactionDetailExtraInfo],
actions: [TransactionDetailAction],
buttonTitle: String = L10n.done
bottomActions: [TransactionBottomAction] = [.done]
) {
self.status = status
self.title = title
Expand All @@ -33,7 +33,7 @@ struct MockedRendableDetailTransaction: RenderableTransactionDetail {
self.amountInToken = amountInToken
self.extra = extra
self.actions = actions
self.buttonTitle = buttonTitle
self.bottomActions = bottomActions
}

static func send() -> Self {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,27 +302,27 @@ struct RendableDetailPendingTransaction: RenderableTransactionDetail {
}
}

var buttonTitle: String {
var bottomActions: [TransactionBottomAction] {
switch trx.rawTransaction {
case _ as SwapRawTransactionType:
switch status {
case let .error(_, error):
if let error, error.isSlippageError {
return L10n.increaseSlippageAndTryAgain
return [.increaseSlippageAndTryAgain]
} else {
return L10n.tryAgain
return [.tryAgain]
}
default:
return L10n.done
return [.done]
}

default:
return L10n.done
return [.done]
}
}

var url: String? {
"https://explorer.solana.com/tx/\(signature ?? "")"
"https://solscan.io/tx/\(signature ?? "")"
}
}

Expand Down
Loading
Loading