Skip to content

Commit

Permalink
Merge pull request #1712 from p2p-org/feature/pwn-1033
Browse files Browse the repository at this point in the history
Fix wormhole feature flag doesn't work
  • Loading branch information
lisemyon authored Feb 21, 2024
2 parents 4b22e71 + 5cea3dc commit 655ff06
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 13 deletions.
1 change: 1 addition & 0 deletions p2p_wallet/Scenes/DebugMenu/View/DebugMenuView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ struct DebugMenuView: View {
NavigationLink("Socket", destination: SocketDebugView())
NavigationLink("Web3Auth", destination: OnboardingDebugView())
NavigationLink("History") { HistoryDebugView() }
NavigationLink("Flags") { FlagDebugMenuView() }
}
}

Expand Down
27 changes: 27 additions & 0 deletions p2p_wallet/Scenes/DebugMenu/View/FlagDebugMenuView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import SwiftUI

struct FlagDebugMenuView: View {
var body: some View {
List {
DebugText(title: "ETH Address", value: "\(available(.ethAddressEnabled))")
DebugText(title: "Invest Solend", value: "\(available(.investSolendFeature))")
DebugText(title: "Mocked API Gateway", value: "\(available(.mockedApiGateway))")
DebugText(title: "Mocked TKey Facade", value: "\(available(.mockedTKeyFacade))")
DebugText(title: "Onboarding Username", value: "\(available(.onboardingUsernameEnabled))")
DebugText(
title: "Onboarding Username Button Skip",
value: "\(available(.onboardingUsernameButtonSkipEnabled))"
)
DebugText(title: "PnL", value: "\(available(.pnlEnabled))")
DebugText(title: "Referral Program", value: "\(available(.referralProgramEnabled))")
DebugText(title: "Send Via Link", value: "\(available(.sendViaLinkEnabled))")
DebugText(title: "Simulated Social Error", value: "\(available(.simulatedSocialError))")
DebugText(title: "Solana ETH Address", value: "\(available(.solanaEthAddressEnabled))")
DebugText(title: "Solana Negative Status", value: "\(available(.solanaNegativeStatus))")
DebugText(title: "Solend Disable Placeholder", value: "\(available(.solendDisablePlaceholder))")
DebugText(title: "Swap Transaction Simulation", value: "\(available(.swapTransactionSimulationEnabled))")
DebugText(title: "Sell Scenario", value: "\(available(.sellScenarioEnabled))")
}
.navigationTitle("Flags")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,22 @@ class RecipientSearchViewModel: ObservableObject {
self.flow = flow

let ethereumSearch: Bool
if let preChosenWallet {
// Check token is support wormhole
if WormholeSupportedTokens.bridges
.map(\.solAddress).contains(preChosenWallet.token.mintAddress)
{
ethereumSearch = true
if !available(.ethAddressEnabled) {
ethereumSearch = false
} else {
if let preChosenWallet {
// Check token is support wormhole
if WormholeSupportedTokens.bridges
.map(\.solAddress).contains(preChosenWallet.token.mintAddress)
{
ethereumSearch = true
} else {
ethereumSearch = false
}
} else {
ethereumSearch = false
// No pre chosen, search all
ethereumSearch = true
}
} else {
// No pre chosen, search all
ethereumSearch = true
}

config = .init(
Expand All @@ -122,7 +126,7 @@ class RecipientSearchViewModel: ObservableObject {
Task {
let tokens = try await tokensRepository.all()
await MainActor.run { [weak self] in
guard let self = self else { return }
guard let self else { return }
self.config.tokens = tokens
}
}
Expand All @@ -143,7 +147,7 @@ class RecipientSearchViewModel: ObservableObject {
.combineLatest($config)
.debounce(for: 0.2, scheduler: DispatchQueue.main)
.sink { [weak self] (query: String, _) in
guard let self = self else { return }
guard let self else { return }
self.search(
query: query,
autoSelectTheOnlyOneResultMode: self.autoSelectTheOnlyOneResultMode,
Expand Down Expand Up @@ -206,7 +210,7 @@ class RecipientSearchViewModel: ObservableObject {
self?.searchResult = result
}
if
let autoSelectTheOnlyOneResultMode = autoSelectTheOnlyOneResultMode,
let autoSelectTheOnlyOneResultMode,
autoSelectTheOnlyOneResultMode.isEnabled
{
try? await Task.sleep(nanoseconds: autoSelectTheOnlyOneResultMode.delay!)
Expand Down

0 comments on commit 655ff06

Please sign in to comment.