Skip to content

Commit c5b057e

Browse files
committed
chore: localize the onramp deeplink errors to the provider
Signed-off-by: Brandon McAnsh <[email protected]>
1 parent 95f1852 commit c5b057e

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -295,28 +295,28 @@
295295
<string name="error_title_deeplinkOnRampFailedToSendTransaction">Transaction Failed</string>
296296
<string name="error_title_deeplinkOnRampDisconnected">Something Went Wrong</string>
297297
<string name="error_title_deeplinkOnRampUnauthorized">Something Went Wrong</string>
298-
<string name="error_title_deeplinkOnRampUserRejected">Request Rejected in Phantom</string>
298+
<string name="error_title_deeplinkOnRampUserRejected">Request Rejected in %1$s</string>
299299
<string name="error_title_deeplinkOnRampInvalidInput">Something Went Wrong</string>
300300
<string name="error_title_deeplinkOnRampRequestedResourceNotAvailable">Something Went Wrong</string>
301301
<string name="error_title_deeplinkOnRampTransactionRejected">Something Went Wrong</string>
302302
<string name="error_title_deeplinkOnRampMethodNotFound">Something Went Wrong</string>
303303
<string name="error_title_deeplinkOnRampInternalError">Something Went Wrong</string>
304304
<string name="error_title_deeplinkOnRampUnknown">Something Went Wrong</string>
305305

306-
<string name="error_description_deeplinkOnRampDecryption">Response from Phantom failed. Please try again</string>
307-
<string name="error_description_deeplinkOnRampDeserialization">Response from Phantom failed. Please try again</string>
306+
<string name="error_description_deeplinkOnRampDecryption">Response from %1$s failed. Please try again</string>
307+
<string name="error_description_deeplinkOnRampDeserialization">Response from %1$s failed. Please try again</string>
308308
<string name="error_description_deeplinkOnRampFailedToCreateTransaction">Failed to generate transaction. Please try again</string>
309309
<string name="error_description_deeplinkOnRampFailedToSimulateTransaction">Failed to simulate transaction on chain. Please try again</string>
310310
<string name="error_description_deeplinkOnRampFailedToCreateDeeplink">Failed to generate transaction. Please try again</string>
311-
<string name="error_description_deeplinkOnRampFailedToSendTransaction">Make sure you have enough Solana USDC and enough SOL in your Phantom account to complete the transaction</string>
312-
<string name="error_description_deeplinkOnRampDisconnected">Phantom could not connect to the network. Please try again</string>
311+
<string name="error_description_deeplinkOnRampFailedToSendTransaction">Make sure you have enough Solana USDC and enough SOL in your %1$s account to complete the transaction</string>
312+
<string name="error_description_deeplinkOnRampDisconnected">%1$s could not connect to the network. Please try again</string>
313313
<string name="error_description_deeplinkOnRampUnauthorized">The request has not been authorized by the user</string>
314-
<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_deeplinkOnRampUserRejected">Make sure you have enough Solana USDC and enough SOL in your %1$s account to complete the transaction</string>
315315
<string name="error_description_deeplinkOnRampInvalidInput">The request was invalid. Please try again</string>
316-
<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>
317-
<string name="error_description_deeplinkOnRampTransactionRejected">The transaction sent to Phantom was invalid</string>
318-
<string name="error_description_deeplinkOnRampMethodNotFound">Phantom did not recognize the request</string>
319-
<string name="error_description_deeplinkOnRampInternalError">Something went wrong within Phantom. Please try again</string>
316+
<string name="error_description_deeplinkOnRampRequestedResourceNotAvailable">The requested resource is not available. This can occur if a previous confirmation modal was not closed in %1$s before requesting a new approval</string>
317+
<string name="error_description_deeplinkOnRampTransactionRejected">The transaction sent to %1$s was invalid</string>
318+
<string name="error_description_deeplinkOnRampMethodNotFound">%1$s did not recognize the request</string>
319+
<string name="error_description_deeplinkOnRampInternalError">Something went wrong within %1$s. Please try again</string>
320320
<string name="error_description_deeplinkOnRampUnknown">Please try again</string>
321321

322322
<string name="title_verifyPhoneNumber">Verify Phone Number</string>

apps/flipcash/shared/onramp/deeplinks/src/main/kotlin/com/flipcash/app/onramp/ExternalWalletOnRampHandler.kt

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.flipcash.app.onramp.internal.ExternalWalletState
1818
import com.flipcash.app.onramp.internal.buildConnectDeeplink
1919
import com.flipcash.app.onramp.internal.buildTransactionDeeplink
2020
import com.flipcash.app.router.Router
21+
import com.flipcash.services.internal.model.thirdparty.OnRampProvider
2122
import com.flipcash.shared.onramp.deeplinks.R
2223
import com.getcode.manager.BottomBarAction
2324
import com.getcode.manager.BottomBarManager
@@ -81,7 +82,15 @@ fun ExternalWalletOnRampHandler(
8182
) {
8283
state.errors
8384
.onEach { error ->
84-
val (title, message) = error.messaging(context)
85+
val (title, message) = error.messaging(
86+
context = context,
87+
provider = when (state.provider) {
88+
OnRampProvider.Backpack -> context.getString(R.string.label_backpack)
89+
OnRampProvider.Phantom -> context.getString(R.string.label_phantom)
90+
OnRampProvider.Solflare -> context.getString(R.string.label_solflare)
91+
null -> ""
92+
}
93+
)
8594
trace(
8695
tag = TAG,
8796
message = "Something went wrong during deeplink onramp",
@@ -250,21 +259,21 @@ private const val TAG = "onramp::deeplinks"
250259
private typealias Title = String
251260
private typealias Message = String
252261

253-
private fun DeeplinkOnRampError.messaging(context: Context): Pair<Title, Message> = when (this) {
254-
is DeeplinkOnRampError.DecryptionError -> context.getString(R.string.error_title_deeplinkOnRampDecryption) to context.getString(R.string.error_description_deeplinkOnRampDecryption)
255-
is DeeplinkOnRampError.DeserializationError -> context.getString(R.string.error_title_deeplinkOnRampDeserialization) to context.getString(R.string.error_description_deeplinkOnRampDeserialization)
262+
private fun DeeplinkOnRampError.messaging(context: Context, provider: String): Pair<Title, Message> = when (this) {
263+
is DeeplinkOnRampError.DecryptionError -> context.getString(R.string.error_title_deeplinkOnRampDecryption) to context.getString(R.string.error_description_deeplinkOnRampDecryption).format(provider)
264+
is DeeplinkOnRampError.DeserializationError -> context.getString(R.string.error_title_deeplinkOnRampDeserialization) to context.getString(R.string.error_description_deeplinkOnRampDeserialization).format(provider)
256265
is DeeplinkOnRampError.FailedToCreateTransaction -> context.getString(R.string.error_title_deeplinkOnRampFailedToCreateTransaction) to context.getString(R.string.error_description_deeplinkOnRampFailedToCreateTransaction)
257266
is DeeplinkOnRampError.FailedToSimulateTransaction -> context.getString(R.string.error_title_deeplinkOnRampFailedToSimulateTransaction) to context.getString(R.string.error_description_deeplinkOnRampFailedToSimulateTransaction)
258267
is DeeplinkOnRampError.FailedToGenerateDeeplink -> context.getString(R.string.error_title_deeplinkOnRampFailedToCreateDeeplink) to context.getString(R.string.error_description_deeplinkOnRampFailedToCreateDeeplink)
259-
is DeeplinkOnRampError.FailedToSendTransaction -> context.getString(R.string.error_title_deeplinkOnRampFailedToSendTransaction) to context.getString(R.string.error_description_deeplinkOnRampFailedToSendTransaction)
268+
is DeeplinkOnRampError.FailedToSendTransaction -> context.getString(R.string.error_title_deeplinkOnRampFailedToSendTransaction) to context.getString(R.string.error_description_deeplinkOnRampFailedToSendTransaction).format(provider)
260269
is DeeplinkOnRampError.WalletProvidedError -> when (this.error) {
261-
DeeplinkError.Disconnected -> context.getString(R.string.error_title_deeplinkOnRampDisconnected) to context.getString(R.string.error_description_deeplinkOnRampDisconnected)
270+
DeeplinkError.Disconnected -> context.getString(R.string.error_title_deeplinkOnRampDisconnected) to context.getString(R.string.error_description_deeplinkOnRampDisconnected).format(provider)
262271
DeeplinkError.Unauthorized -> context.getString(R.string.error_title_deeplinkOnRampUnauthorized) to context.getString(R.string.error_description_deeplinkOnRampUnauthorized)
263-
DeeplinkError.UserRejectedRequest -> context.getString(R.string.error_title_deeplinkOnRampUserRejected) to context.getString(R.string.error_description_deeplinkOnRampUserRejected)
272+
DeeplinkError.UserRejectedRequest -> context.getString(R.string.error_title_deeplinkOnRampUserRejected).format(provider) to context.getString(R.string.error_description_deeplinkOnRampUserRejected).format(provider)
264273
DeeplinkError.InvalidInput -> context.getString(R.string.error_title_deeplinkOnRampInvalidInput) to context.getString(R.string.error_description_deeplinkOnRampInvalidInput)
265-
DeeplinkError.RequestedResourceNotAvailable -> context.getString(R.string.error_title_deeplinkOnRampRequestedResourceNotAvailable) to context.getString(R.string.error_description_deeplinkOnRampRequestedResourceNotAvailable)
266-
DeeplinkError.TransactionRejected -> context.getString(R.string.error_title_deeplinkOnRampTransactionRejected) to context.getString(R.string.error_description_deeplinkOnRampTransactionRejected)
267-
DeeplinkError.MethodNotFound -> context.getString(R.string.error_title_deeplinkOnRampMethodNotFound) to context.getString(R.string.error_description_deeplinkOnRampMethodNotFound)
274+
DeeplinkError.RequestedResourceNotAvailable -> context.getString(R.string.error_title_deeplinkOnRampRequestedResourceNotAvailable) to context.getString(R.string.error_description_deeplinkOnRampRequestedResourceNotAvailable).format(provider)
275+
DeeplinkError.TransactionRejected -> context.getString(R.string.error_title_deeplinkOnRampTransactionRejected) to context.getString(R.string.error_description_deeplinkOnRampTransactionRejected).format(provider)
276+
DeeplinkError.MethodNotFound -> context.getString(R.string.error_title_deeplinkOnRampMethodNotFound) to context.getString(R.string.error_description_deeplinkOnRampMethodNotFound).format(provider)
268277
DeeplinkError.InternalError -> context.getString(R.string.error_title_deeplinkOnRampInternalError) to context.getString(R.string.error_description_deeplinkOnRampInternalError)
269278
DeeplinkError.Unknown -> context.getString(R.string.error_title_deeplinkOnRampUnknown) to context.getString(R.string.error_description_deeplinkOnRampUnknown)
270279
}

0 commit comments

Comments
 (0)