Skip to content

Commit 1084546

Browse files
committed
chore: add dedicated FeatureFlag to enable the Coinbase sandbox
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent e3a1819 commit 1084546

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

apps/flipcash/shared/featureflags/src/main/kotlin/com/flipcash/app/featureflags/FeatureFlag.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,15 @@ sealed interface FeatureFlag {
109109
override val persistLogOut: Boolean = false
110110
}
111111

112+
@FeatureFlagMarker
113+
data object CoinbaseOnRampSandbox: FeatureFlag {
114+
override val key: String = "coinbase_onramp_sandbox_enabled"
115+
override val default: Boolean = false
116+
override val launched: Boolean = false
117+
override val visible: Boolean = true
118+
override val persistLogOut: Boolean = false
119+
}
120+
112121
@FeatureFlagMarker
113122
data object TokenDiscovery: FeatureFlag {
114123
override val key: String = "token_discovery_enabled"
@@ -151,6 +160,7 @@ val FeatureFlag.title: String
151160
FeatureFlag.CashReservesEnabled -> "Cash Reserves"
152161
FeatureFlag.MarketCapChart -> "Market Cap Chart"
153162
FeatureFlag.CoinbaseOnRamp -> "Coinbase Onramp"
163+
FeatureFlag.CoinbaseOnRampSandbox -> "Coinbase Onramp Sandbox"
154164
FeatureFlag.TokenDiscovery -> "Token Discovery"
155165
FeatureFlag.TokenCreate -> "Token Creation"
156166
}
@@ -168,6 +178,7 @@ val FeatureFlag.message: String
168178
FeatureFlag.CashReservesEnabled -> "When enabled, USDC will be brandished as Cash Reserves throughout the app"
169179
FeatureFlag.MarketCapChart -> "When enabled, you'll gain access to the market cap chart in token info"
170180
FeatureFlag.CoinbaseOnRamp -> "When enabled, you'll gain access to the Coinbase onramp for token buys"
181+
FeatureFlag.CoinbaseOnRampSandbox -> "When enabled, Coinbase onramp purchases will use the sandbox environment for testing"
171182
FeatureFlag.TokenDiscovery -> "When enabled, you'll gain access to leaderboards for tokens and discovery"
172183
FeatureFlag.TokenCreate -> "When enabled, you'll gain access to create new currencies"
173184
}

apps/flipcash/shared/onramp/coinbase/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies {
1717
implementation(libs.androidx.localbroadcastmanager)
1818
implementation(libs.kotlinx.serialization.json)
1919

20+
implementation(project(":apps:flipcash:shared:featureflags"))
2021
implementation(project(":apps:flipcash:shared:web"))
2122
api(project(":libs:network:coinbase:onramp"))
2223
implementation(project(":libs:network:jwt"))

apps/flipcash/shared/onramp/coinbase/src/main/kotlin/com/flipcash/app/onramp/OnRampController.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.coinbase.onramp.data.OnRampApiConfig
66
import com.coinbase.onramp.data.OnRampPaymentMethod
77
import com.coinbase.onramp.data.OnRampPurchaseRequest
88
import com.coinbase.onramp.data.OnRampPurchaseResponse
9+
import com.flipcash.app.featureflags.FeatureFlag
10+
import com.flipcash.app.featureflags.FeatureFlagController
911
import com.flipcash.services.models.GetJwtError
1012
import com.flipcash.services.user.UserManager
1113
import com.flipcash.shared.onramp.coinbase.BuildConfig
@@ -36,6 +38,7 @@ class OnRampController @Inject constructor(
3638
private val api: CoinbaseApi,
3739
private val userManager: UserManager,
3840
private val exchange: Exchange,
41+
private val featureFlags: FeatureFlagController,
3942
) {
4043

4144
suspend fun placeOrderInclusiveOfFees(
@@ -69,7 +72,8 @@ class OnRampController @Inject constructor(
6972
)
7073
}
7174

72-
val partnerRef = if (onRampApiEndpoint.useSandbox) "sandbox-$userRef" else userRef
75+
val useSandbox = featureFlags.get(FeatureFlag.CoinbaseOnRampSandbox)
76+
val partnerRef = if (useSandbox) "sandbox-$userRef" else userRef
7377

7478
val order = OnRampPurchaseRequest.InclusiveOfFees(
7579
paymentAmount = usdAmount,
@@ -114,7 +118,8 @@ class OnRampController @Inject constructor(
114118
)
115119
}
116120

117-
val partnerRef = if (onRampApiEndpoint.useSandbox) "sandbox-$userRef" else userRef
121+
val useSandbox = featureFlags.get(FeatureFlag.CoinbaseOnRampSandbox)
122+
val partnerRef = if (useSandbox) "sandbox-$userRef" else userRef
118123

119124
val order = OnRampPurchaseRequest.ExclusiveOfFees(
120125
purchaseAmount = usdAmount,
@@ -189,6 +194,7 @@ class OnRampController @Inject constructor(
189194
order: OnRampPurchaseRequest,
190195
endpoint: OnRampApiConfig,
191196
): Result<OrderWithPaymentLink> {
197+
val useSandbox = featureFlags.get(FeatureFlag.CoinbaseOnRampSandbox)
192198
return requestJwtAndExecute(
193199
scheme = endpoint.scheme,
194200
host = endpoint.host,
@@ -205,7 +211,7 @@ class OnRampController @Inject constructor(
205211
response.copy(
206212
paymentLink = response.paymentLink.copy(
207213
url = response.paymentLink.url.let { url ->
208-
if (onRampApiEndpoint.useSandbox) {
214+
if (useSandbox) {
209215
url.toUri().buildUpon()
210216
.appendQueryParameter("useGooglePaySandbox", "true")
211217
.build()

libs/network/coinbase/onramp/src/main/kotlin/com/coinbase/onramp/data/OnRampApiConfig.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ data class OnRampApiConfig(
55
val host: String,
66
val path: String,
77
val method: String,
8-
val useSandbox: Boolean = false,
98
) {
109
val baseUrl: String
1110
get() = "$scheme://$host"

libs/network/coinbase/onramp/src/main/kotlin/com/coinbase/onramp/internal/CoinbaseModule.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ object CoinbaseModule {
3232
host = "api.cdp.coinbase.com/platform/",
3333
path = "/v2/onramp/orders",
3434
method = "POST",
35-
useSandbox = true // for now
3635
)
3736

3837
@Singleton

0 commit comments

Comments
 (0)