Skip to content

Commit 26376bc

Browse files
committed
feat(token/purchase): add "Other Wallet" to purchase methods for token buys
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent c62fb02 commit 26376bc

4 files changed

Lines changed: 19 additions & 6 deletions

File tree

apps/flipcash/features/currency-creator/src/main/kotlin/com/flipcash/app/currencycreator/internal/CurrencyCreatorViewModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ internal class CurrencyCreatorViewModel @Inject constructor(
421421
purchaseAmount = stateFlow.value.totalCost,
422422
feeAmount = stateFlow.value.feeAmount,
423423
paymentAction = PaymentAction.Pay,
424+
canUseOtherWallets = false, // can not use external deposit for this flow
424425
)
425426
purchaseMethodController.present(metadata)
426427
}

apps/flipcash/features/tokens/src/main/kotlin/com/flipcash/app/tokens/SwapEntryScreen.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ import com.getcode.navigation.core.LocalCodeNavigator
2121
import com.getcode.navigation.flow.flowSharedViewModel
2222
import com.getcode.navigation.flow.rememberFlowNavigator
2323
import com.getcode.opencode.model.financial.Fiat
24+
import com.getcode.solana.keys.Mint
2425
import com.getcode.ui.components.AppBarWithTitle
25-
import com.getcode.ui.core.rememberAnimationScale
26-
import com.getcode.ui.core.scaled
27-
import kotlinx.coroutines.delay
2826
import kotlinx.coroutines.flow.filterIsInstance
2927
import kotlinx.coroutines.flow.launchIn
3028
import kotlinx.coroutines.flow.map
@@ -112,16 +110,22 @@ internal fun SwapEntryScreen(
112110
}.launchIn(this)
113111
}
114112

115-
val animationScale by rememberAnimationScale()
116113
LaunchedEffect(viewModel) {
117114
viewModel.eventFlow
118115
.filterIsInstance<SwapViewModel.Event.PhantomSelected>()
119-
.onEach { delay(300.scaled(animationScale)) }
120116
.onEach {
121117
flowNavigator.navigateTo(SwapStep.PhantomConnect)
122118
}.launchIn(this)
123119
}
124120

121+
LaunchedEffect(viewModel) {
122+
viewModel.eventFlow
123+
.filterIsInstance<SwapViewModel.Event.OtherWalletSelected>()
124+
.onEach {
125+
navigator.push(AppRoute.Transfers.Deposit(Mint.usdf))
126+
}.launchIn(this)
127+
}
128+
125129
LaunchedEffect(Unit) {
126130
coinbaseOnRampController.pendingNavigation.collect { route ->
127131
if (route is AppRoute.Token.TxProcessing) {

apps/flipcash/shared/analytics/src/main/kotlin/com/flipcash/app/analytics/Actions.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ sealed interface Button: AppAction {
4545
override val value: String = "Button: Buy With Coinbase"
4646
}
4747

48+
data object TokenBuyWithOtherWallet : Button {
49+
override val value: String = "Button: Buy With Other Wallet"
50+
}
51+
4852
data object TokenSell : Button {
4953
override val value: String = "Button: Sell"
5054
}

apps/flipcash/shared/tokens/src/main/kotlin/com/flipcash/app/tokens/ui/SwapViewModel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ class SwapViewModel @Inject constructor(
218218

219219
data class OnCurrencyChanged(val currency: Currency) : Event
220220

221+
data object OtherWalletSelected: Event
221222
data object CoinbaseSelected : Event
222223
data object PhantomSelected : Event
223224
data object ConfirmPhantomTransaction : Event
@@ -547,6 +548,7 @@ class SwapViewModel @Inject constructor(
547548
val metadata = PurchaseMethodMetadata(
548549
mint = mint,
549550
purchaseAmount = Fiat(data.amountData.amount, rate.currency),
551+
canUseOtherWallets = true, // allow external USDC deposit as a "purchase" option
550552
)
551553
val methods = purchaseMethodController.state.value.availableMethods
552554
if (methods.size == 1) {
@@ -833,7 +835,8 @@ class SwapViewModel @Inject constructor(
833835
}
834836

835837
PurchaseMethod.OtherWallet -> {
836-
// TODO:
838+
analytics.buttonTapped(Button.TokenBuyWithOtherWallet)
839+
dispatchEvent(Event.OtherWalletSelected)
837840
}
838841
}
839842
}.launchIn(viewModelScope)
@@ -1166,6 +1169,7 @@ class SwapViewModel @Inject constructor(
11661169
}
11671170
}
11681171

1172+
Event.OtherWalletSelected,
11691173
Event.ConfirmPhantomTransaction,
11701174
Event.StartPhantomCeremony,
11711175
Event.PhantomConnected,

0 commit comments

Comments
 (0)