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 @@ -421,6 +421,7 @@ internal class CurrencyCreatorViewModel @Inject constructor(
purchaseAmount = stateFlow.value.totalCost,
feeAmount = stateFlow.value.feeAmount,
paymentAction = PaymentAction.Pay,
canUseOtherWallets = false, // can not use external deposit for this flow
)
purchaseMethodController.present(metadata)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ import com.getcode.navigation.core.LocalCodeNavigator
import com.getcode.navigation.flow.flowSharedViewModel
import com.getcode.navigation.flow.rememberFlowNavigator
import com.getcode.opencode.model.financial.Fiat
import com.getcode.solana.keys.Mint
import com.getcode.ui.components.AppBarWithTitle
import com.getcode.ui.core.rememberAnimationScale
import com.getcode.ui.core.scaled
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.filterIsInstance
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -112,16 +110,22 @@ internal fun SwapEntryScreen(
}.launchIn(this)
}

val animationScale by rememberAnimationScale()
LaunchedEffect(viewModel) {
viewModel.eventFlow
.filterIsInstance<SwapViewModel.Event.PhantomSelected>()
.onEach { delay(300.scaled(animationScale)) }
.onEach {
flowNavigator.navigateTo(SwapStep.PhantomConnect)
}.launchIn(this)
}

LaunchedEffect(viewModel) {
viewModel.eventFlow
.filterIsInstance<SwapViewModel.Event.OtherWalletSelected>()
.onEach {
navigator.push(AppRoute.Transfers.Deposit(Mint.usdf))
}.launchIn(this)
}

LaunchedEffect(Unit) {
coinbaseOnRampController.pendingNavigation.collect { route ->
if (route is AppRoute.Token.TxProcessing) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ sealed interface Button: AppAction {
override val value: String = "Button: Buy With Coinbase"
}

data object TokenBuyWithOtherWallet : Button {
override val value: String = "Button: Buy With Other Wallet"
}

data object TokenSell : Button {
override val value: String = "Button: Sell"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ class SwapViewModel @Inject constructor(

data class OnCurrencyChanged(val currency: Currency) : Event

data object OtherWalletSelected: Event
data object CoinbaseSelected : Event
data object PhantomSelected : Event
data object ConfirmPhantomTransaction : Event
Expand Down Expand Up @@ -547,6 +548,7 @@ class SwapViewModel @Inject constructor(
val metadata = PurchaseMethodMetadata(
mint = mint,
purchaseAmount = Fiat(data.amountData.amount, rate.currency),
canUseOtherWallets = true, // allow external USDC deposit as a "purchase" option
)
val methods = purchaseMethodController.state.value.availableMethods
if (methods.size == 1) {
Expand Down Expand Up @@ -833,7 +835,8 @@ class SwapViewModel @Inject constructor(
}

PurchaseMethod.OtherWallet -> {
// TODO:
analytics.buttonTapped(Button.TokenBuyWithOtherWallet)
dispatchEvent(Event.OtherWalletSelected)
}
}
}.launchIn(viewModelScope)
Expand Down Expand Up @@ -1166,6 +1169,7 @@ class SwapViewModel @Inject constructor(
}
}

Event.OtherWalletSelected,
Event.ConfirmPhantomTransaction,
Event.StartPhantomCeremony,
Event.PhantomConnected,
Expand Down
Loading