Skip to content

Commit e993cc2

Browse files
committed
feat(flipcash): add support for onramp via backpack and solflare
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 23d7284 commit e993cc2

39 files changed

Lines changed: 758 additions & 443 deletions

File tree

apps/flipcash/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ dependencies {
149149
implementation(project(":apps:flipcash:shared:notifications"))
150150
implementation(project(":apps:flipcash:shared:onramp:common"))
151151
implementation(project(":apps:flipcash:shared:onramp:coinbase"))
152-
implementation(project(":apps:flipcash:shared:onramp:phantom"))
152+
implementation(project(":apps:flipcash:shared:onramp:deeplinks"))
153153
implementation(project(":apps:flipcash:shared:payments"))
154154
implementation(project(":apps:flipcash:shared:permissions"))
155155
implementation(project(":apps:flipcash:shared:phone"))

apps/flipcash/app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686

8787
<data
8888
android:host="app.flipcash.com"
89-
android:pathPattern="/phantom/connected"
89+
android:pathPattern="/external/.*/connected"
9090
android:scheme="https" />
9191
</intent-filter>
9292

@@ -98,7 +98,7 @@
9898

9999
<data
100100
android:host="app.flipcash.com"
101-
android:pathPattern="/phantom/signed"
101+
android:pathPattern="/external/.*/signed"
102102
android:scheme="https" />
103103
</intent-filter>
104104

apps/flipcash/app/src/main/kotlin/com/flipcash/app/internal/ui/App.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ import com.flipcash.app.core.AppRoute
3030
import com.flipcash.app.core.navigation.DeeplinkType
3131
import com.flipcash.app.internal.ui.navigation.AppScreenContent
3232
import com.flipcash.app.internal.ui.navigation.MainRoot
33-
import com.flipcash.app.onramp.LocalPhantomDepositState
33+
import com.flipcash.app.onramp.ExternalWalletOnRampHandler
34+
import com.flipcash.app.onramp.LocalExternalWalletState
3435
import com.flipcash.app.onramp.OnRampAmountScaffold
35-
import com.flipcash.app.onramp.PhantomOnRampHandler
36-
import com.flipcash.app.onramp.rememberPhantomDepositState
36+
import com.flipcash.app.onramp.rememberExternalWalletState
3737
import com.flipcash.app.payments.PaymentScaffold
3838
import com.flipcash.app.router.LocalRouter
3939
import com.flipcash.app.session.LocalSessionController
@@ -118,19 +118,19 @@ internal fun App(
118118
)
119119

120120
val barManager = rememberBarManager()
121-
val phantomDepositState = rememberPhantomDepositState(solanaRpcConfig)
121+
val externalWalletOnRamp = rememberExternalWalletState(solanaRpcConfig)
122122

123123
CompositionLocalProvider(
124-
LocalPhantomDepositState provides phantomDepositState
124+
LocalExternalWalletState provides externalWalletOnRamp
125125
) {
126126
AppScreenContent {
127127
PaymentScaffold {
128128
OnRampAmountScaffold {
129129
TipScaffold(tipsEngine = tipsEngine) {
130130
AppNavHost(biometricsState) {
131131
val codeNavigator = LocalCodeNavigator.current
132-
PhantomOnRampHandler(
133-
state = LocalPhantomDepositState.current,
132+
ExternalWalletOnRampHandler(
133+
state = externalWalletOnRamp,
134134
lifecycleOwner = LocalLifecycleOwner.current,
135135
navigator = codeNavigator,
136136
router = router,

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/navigation/DeeplinkType.kt

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ package com.flipcash.app.core.navigation
22

33
import android.net.Uri
44
import android.os.Parcelable
5-
import com.flipcash.app.core.AppRoute
6-
import com.flipcash.app.core.phantom.PhantomConnectionResult
7-
import com.flipcash.app.core.phantom.PhantomDeeplinkError
8-
import com.flipcash.app.core.phantom.PhantomDeeplinkOrigin
9-
import com.flipcash.app.core.phantom.PhantomSigningResult
10-
import com.flipcash.app.core.verification.email.EmailDeeplinkOrigin
5+
import com.flipcash.app.core.onramp.deeplinks.WalletDeeplinkConnectionResult
6+
import com.flipcash.app.core.onramp.deeplinks.ExternalWalletDeeplinkError
7+
import com.flipcash.app.core.onramp.deeplinks.OnRampDeeplinkOrigin
8+
import com.flipcash.app.core.onramp.deeplinks.WalletDeeplinkSigningResult
119
import com.getcode.ed25519.Ed25519
12-
import com.getcode.opencode.model.core.ID
1310
import com.getcode.vendor.Base58
1411
import kotlinx.parcelize.Parcelize
1512

@@ -23,17 +20,21 @@ sealed interface DeeplinkType: Parcelable {
2320
get() = Ed25519.createKeyPair(Base58.decode(seed))
2421
}
2522

26-
data class PhantomConnection(
27-
val origin: PhantomDeeplinkOrigin,
28-
val result: PhantomConnectionResult?,
29-
val error: PhantomDeeplinkError? = null
30-
): DeeplinkType, Navigatable
23+
sealed interface ExternalWalletStep {
24+
val origin: OnRampDeeplinkOrigin
25+
}
3126

32-
data class PhantomSignedTransaction(
33-
val origin: PhantomDeeplinkOrigin,
34-
val result: PhantomSigningResult?,
35-
val error: PhantomDeeplinkError? = null
36-
): DeeplinkType, Navigatable
27+
data class ExternalWalletConnection(
28+
override val origin: OnRampDeeplinkOrigin,
29+
val result: WalletDeeplinkConnectionResult?,
30+
val error: ExternalWalletDeeplinkError? = null
31+
): DeeplinkType, ExternalWalletStep, Navigatable
32+
33+
data class ExternalWalletSignedTransaction(
34+
override val origin: OnRampDeeplinkOrigin,
35+
val result: WalletDeeplinkSigningResult?,
36+
val error: ExternalWalletDeeplinkError? = null
37+
): DeeplinkType, ExternalWalletStep, Navigatable
3738

3839
data class EmailVerification(
3940
val email: String,

apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/phantom/PhantomConnectionResult.kt renamed to apps/flipcash/core/src/main/kotlin/com/flipcash/app/core/onramp/deeplinks/WalletDeeplinkConnectionResult.kt

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.flipcash.app.core.phantom
1+
package com.flipcash.app.core.onramp.deeplinks
22

33
import android.os.Parcelable
44
import com.flipcash.app.core.AppRoute
@@ -15,35 +15,35 @@ import kotlinx.serialization.Serializable
1515

1616
@Serializable
1717
@Parcelize
18-
data class PhantomWalletConnection(
18+
data class ExternalWalletConnection(
1919
@SerialName("public_key")
2020
val publicKey: PublicKey,
2121
val session: String,
2222
): Parcelable
2323

2424
@Serializable
2525
@Parcelize
26-
data class PhantomSignedTransaction(
26+
data class ExternallySignedTransaction(
2727
@SerialName("transaction")
2828
val serializedTransaction: String,
2929
): Parcelable
3030

3131
@Parcelize
32-
sealed class PhantomDeeplinkOrigin: Parcelable {
32+
sealed class OnRampDeeplinkOrigin: Parcelable {
3333
@Parcelize
34-
data object Menu : PhantomDeeplinkOrigin()
34+
data object Menu : OnRampDeeplinkOrigin()
3535

3636
@Parcelize
37-
data object Cash: PhantomDeeplinkOrigin()
37+
data object Cash: OnRampDeeplinkOrigin()
3838

3939
@Parcelize
40-
data object Balance: PhantomDeeplinkOrigin()
40+
data object Balance: OnRampDeeplinkOrigin()
4141

4242
@Parcelize
43-
data class PoolWithId(val id: ID) : PhantomDeeplinkOrigin()
43+
data class PoolWithId(val id: ID) : OnRampDeeplinkOrigin()
4444

4545
@Parcelize
46-
data class PoolWithRendezvous(val keyPair: Ed25519.KeyPair) : PhantomDeeplinkOrigin()
46+
data class PoolWithRendezvous(val keyPair: Ed25519.KeyPair) : OnRampDeeplinkOrigin()
4747

4848
fun forUri(): String {
4949
return when(this) {
@@ -55,8 +55,8 @@ sealed class PhantomDeeplinkOrigin: Parcelable {
5555
}.lowercase()
5656
}
5757

58-
companion object {
59-
fun fromRoute(route: AppRoute?): PhantomDeeplinkOrigin? {
58+
companion object Companion {
59+
fun fromRoute(route: AppRoute?): OnRampDeeplinkOrigin? {
6060
return when (route) {
6161
is AppRoute.Sheets.Menu -> Menu
6262
is AppRoute.Sheets.Cash -> Cash
@@ -70,7 +70,7 @@ sealed class PhantomDeeplinkOrigin: Parcelable {
7070
}
7171
}
7272

73-
fun fromString(value: String?): PhantomDeeplinkOrigin? {
73+
fun fromString(value: String?): OnRampDeeplinkOrigin? {
7474
return when {
7575
value == "menu" -> Menu
7676
value == "cash" -> Cash
@@ -93,21 +93,21 @@ sealed class PhantomDeeplinkOrigin: Parcelable {
9393
}
9494

9595
@Parcelize
96-
data class PhantomConnectionResult(
96+
data class WalletDeeplinkConnectionResult(
9797
val encryptionPublicKey: List<Byte>,
9898
val nonce: List<Byte>,
9999
val encryptedData: List<Byte>
100100
): Parcelable
101101

102102
@Parcelize
103-
data class PhantomSigningResult(
103+
data class WalletDeeplinkSigningResult(
104104
val nonce: List<Byte>,
105105
val encryptedData: List<Byte>,
106106
): Parcelable
107107

108108
@Serializable
109109
@Parcelize
110-
data class PhantomDeeplinkError(
110+
data class ExternalWalletDeeplinkError(
111111
val errorCode: String,
112112
val errorMessage: String,
113113
): Parcelable
4.06 KB
Loading

apps/flipcash/core/src/main/res/drawable/ic_phantom.xml renamed to apps/flipcash/core/src/main/res/drawable/ic_phantom_wallet.xml

File renamed without changes.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="196dp"
3+
android:height="208dp"
4+
android:viewportWidth="196"
5+
android:viewportHeight="208">
6+
<path
7+
android:pathData="M98.29,111.85L112.58,98.05L139.21,106.76C156.64,112.58 165.35,123.23 165.35,138.24C165.35,149.62 160.99,157.12 152.28,166.81L149.62,169.71L150.59,162.93C154.46,138.24 147.2,127.59 123.23,119.84L98.29,111.85ZM62.46,27.36L135.09,51.57L119.35,66.58L81.59,53.99C68.51,49.63 64.16,42.61 62.46,27.84V27.36ZM58.1,150.34L74.57,134.61L105.56,144.77C121.78,150.1 127.34,157.12 125.65,174.79L58.1,150.34ZM37.28,80.13C37.28,75.54 39.7,71.18 43.82,67.55C48.18,73.84 55.68,79.41 67.55,83.28L93.21,91.76L78.92,105.56L53.75,97.32C42.13,93.45 37.28,87.64 37.28,80.13ZM113.3,207.24C166.56,171.89 195.13,147.92 195.13,118.39C195.13,98.78 183.51,87.88 157.85,79.41L138.48,72.87L191.5,22.03L180.85,10.65L165.11,24.45L90.79,0C67.79,7.51 38.74,29.54 38.74,51.57C38.74,53.99 38.98,56.41 39.7,59.07C20.58,69.97 12.83,80.13 12.83,92.72C12.83,104.59 19.13,116.45 39.22,122.99L55.2,128.31L0,181.33L10.65,192.71L27.84,176.97L113.3,207.24Z"
8+
android:fillColor="#fff"/>
9+
</vector>

apps/flipcash/core/src/main/res/values/strings.xml

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -286,35 +286,37 @@
286286
<string name="action_dismiss">Dismiss</string>
287287
<string name="title_success">Success</string>
288288

289-
<string name="error_title_phantomDecryption">Something Went Wrong</string>
290-
<string name="error_title_phantomDeserialization">Something Went Wrong</string>
291-
<string name="error_title_phantomFailedToCreateTransaction">Something Went Wrong</string>
292-
<string name="error_title_phantomFailedToCreateDeeplink">Something Went Wrong</string>
293-
<string name="error_title_phantomFailedToSendTransaction">Transaction Failed</string>
294-
<string name="error_title_phantomDisconnected">Something Went Wrong</string>
295-
<string name="error_title_phantomUnauthorized">Something Went Wrong</string>
296-
<string name="error_title_phantomUserRejected">Request Rejected in Phantom</string>
297-
<string name="error_title_phantomInvalidInput">Something Went Wrong</string>
298-
<string name="error_title_phantomRequestedResourceNotAvailable">Something Went Wrong</string>
299-
<string name="error_title_phantomTransactionRejected">Something Went Wrong</string>
300-
<string name="error_title_phantomMethodNotFound">Something Went Wrong</string>
301-
<string name="error_title_phantomInternalError">Something Went Wrong</string>
302-
<string name="error_title_phantomUnknown">Something Went Wrong</string>
303-
304-
<string name="error_description_phantomDecryption">Response from Phantom failed. Please try again</string>
305-
<string name="error_description_phantomDeserialization">Response from Phantom failed. Please try again</string>
306-
<string name="error_description_phantomFailedToCreateTransaction">Failed to generate transaction. Please try again</string>
307-
<string name="error_description_phantomFailedToCreateDeeplink">Failed to generate transaction. Please try again</string>
308-
<string name="error_description_phantomFailedToSendTransaction">Make sure you have enough Solana USDC and enough SOL in your Phantom account to complete the transaction</string>
309-
<string name="error_description_phantomDisconnected">Phantom could not connect to the network. Please try again</string>
310-
<string name="error_description_phantomUnauthorized">The request has not been authorized by the user</string>
311-
<string name="error_description_phantomUserRejected">Make sure you have enough Solana USDC and enough SOL in your Phantom account to complete the transaction</string>
312-
<string name="error_description_phantomInvalidInput">The request was invalid. Please try again</string>
313-
<string name="error_description_phantomRequestedResourceNotAvailable">The requested resource is not available. This can occur if a previous confirmation modal was not closed in Phantom before requesting a new approval</string>
314-
<string name="error_description_phantomTransactionRejected">The transaction sent to Phantom was invalid</string>
315-
<string name="error_description_phantomMethodNotFound">Phantom did not recognize the request</string>
316-
<string name="error_description_phantomInternalError">Something went wrong within Phantom. Please try again</string>
317-
<string name="error_description_phantomUnknown">Please try again</string>
289+
<string name="error_title_deeplinkOnRampDecryption">Something Went Wrong</string>
290+
<string name="error_title_deeplinkOnRampDeserialization">Something Went Wrong</string>
291+
<string name="error_title_deeplinkOnRampFailedToCreateTransaction">Something Went Wrong</string>
292+
<string name="error_title_deeplinkOnRampFailedToSimulateTransaction">Something Went Wrong</string>
293+
<string name="error_title_deeplinkOnRampFailedToCreateDeeplink">Something Went Wrong</string>
294+
<string name="error_title_deeplinkOnRampFailedToSendTransaction">Transaction Failed</string>
295+
<string name="error_title_deeplinkOnRampDisconnected">Something Went Wrong</string>
296+
<string name="error_title_deeplinkOnRampUnauthorized">Something Went Wrong</string>
297+
<string name="error_title_deeplinkOnRampUserRejected">Request Rejected in Phantom</string>
298+
<string name="error_title_deeplinkOnRampInvalidInput">Something Went Wrong</string>
299+
<string name="error_title_deeplinkOnRampRequestedResourceNotAvailable">Something Went Wrong</string>
300+
<string name="error_title_deeplinkOnRampTransactionRejected">Something Went Wrong</string>
301+
<string name="error_title_deeplinkOnRampMethodNotFound">Something Went Wrong</string>
302+
<string name="error_title_deeplinkOnRampInternalError">Something Went Wrong</string>
303+
<string name="error_title_deeplinkOnRampUnknown">Something Went Wrong</string>
304+
305+
<string name="error_description_deeplinkOnRampDecryption">Response from Phantom failed. Please try again</string>
306+
<string name="error_description_deeplinkOnRampDeserialization">Response from Phantom failed. Please try again</string>
307+
<string name="error_description_deeplinkOnRampFailedToCreateTransaction">Failed to generate transaction. Please try again</string>
308+
<string name="error_description_deeplinkOnRampFailedToSimulateTransaction">Failed to simulate transaction on chain. Please try again</string>
309+
<string name="error_description_deeplinkOnRampFailedToCreateDeeplink">Failed to generate transaction. Please try again</string>
310+
<string name="error_description_deeplinkOnRampFailedToSendTransaction">Make sure you have enough Solana USDC and enough SOL in your Phantom account to complete the transaction</string>
311+
<string name="error_description_deeplinkOnRampDisconnected">Phantom could not connect to the network. Please try again</string>
312+
<string name="error_description_deeplinkOnRampUnauthorized">The request has not been authorized by the user</string>
313+
<string name="error_description_deeplinkOnRampUserRejected">Make sure you have enough Solana USDC and enough SOL in your Phantom account to complete the transaction</string>
314+
<string name="error_description_deeplinkOnRampInvalidInput">The request was invalid. Please try again</string>
315+
<string name="error_description_deeplinkOnRampRequestedResourceNotAvailable">The requested resource is not available. This can occur if a previous confirmation modal was not closed in Phantom before requesting a new approval</string>
316+
<string name="error_description_deeplinkOnRampTransactionRejected">The transaction sent to Phantom was invalid</string>
317+
<string name="error_description_deeplinkOnRampMethodNotFound">Phantom did not recognize the request</string>
318+
<string name="error_description_deeplinkOnRampInternalError">Something went wrong within Phantom. Please try again</string>
319+
<string name="error_description_deeplinkOnRampUnknown">Please try again</string>
318320

319321
<string name="title_verifyPhoneNumber">Verify Phone Number</string>
320322
<string name="subtitle_enterPhoneNumberToContinue">Please enter your phone number to continue</string>
@@ -375,12 +377,16 @@
375377
<string name="title_onrampProviderCoinbaseVirtual">Debit Card with Google Pay</string>
376378
<string name="title_onrampProviderCoinbaseDebit">Debit Card</string>
377379
<string name="title_onrampProviderCoinbaseCredit">Credit Card</string>
378-
<string name="title_onrampProviderCryptoWallet">Crypto Wallet</string>
380+
<string name="title_onrampProviderManualDeposit">Manual Deposit</string>
381+
<string name="title_onrampProviderBackpack">Backpack Wallet</string>
379382
<string name="title_onrampProviderPhantom">Phantom Wallet</string>
383+
<string name="title_onrampProviderSolflare">Solflare Wallet</string>
380384

381385
<string name="action_addCashWithGooglePay">Add Cash with Google Pay</string>
382386
<string name="action_addCashWithDebitCard">Add Cash with Debit Card</string>
383387
<string name="action_addCashWithCreditCard">Add Cash with Credit Card</string>
384388
<string name="label_confirmIn">Confirm In</string>
385389
<string name="label_phantom">Phantom</string>
390+
<string name="label_solflare">Solflare</string>
391+
<string name="label_backpack">Backpack</string>
386392
</resources>

apps/flipcash/features/deposit/src/main/kotlin/com/flipcash/app/deposit/DepositScreen.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class DepositScreen : ModalScreen, NamedScreen, Parcelable {
2626
override val key: ScreenKey = uniqueScreenKey
2727

2828
override val name: String
29-
@Composable get() = stringResource(R.string.title_onrampProviderCryptoWallet)
29+
@Composable get() = stringResource(R.string.title_onrampProviderManualDeposit)
3030

3131
@Composable
3232
override fun ModalContent() {

0 commit comments

Comments
 (0)