Skip to content

Feat(coinbase): error handling - #897

Merged
HashEngineering merged 106 commits into
feature-coinbase-integrationfrom
feature-coinbase-error-handling
Feb 24, 2022
Merged

HashEngineering merged 106 commits into
feature-coinbase-integrationfrom
feature-coinbase-error-handling

Conversation

@ClaudeHangui

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

The purpose of this story was to handle the case where a coinbase user would attempt to make a dash purchase for an amount over the authorised limit defined in his account

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • [ x] I have performed a self-review of my own code and added comments where necessary
  • I have added or updated relevant unit/integration/functional/e2e tests

Syn-McJ and others added 30 commits December 14, 2021 13:00
…itory and an implementation for the interface

- set up web services for payment_methods, place_buy_order, commit_order and send_funds_to_wallet
…to feature-buy-dash-data

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…r_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
…1131_Buy_Dash_UI_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…i models

- update implementation in CoinBaseRepository.kt and CoinbaseServicesViewModel.kt to for buy/commit/send flows
…to feature-buy-dash-data

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
…t.kt

- change user authorization scope for coinbase in CoinBaseWebClientActivity.kt
- inject wallet data provider in WalletDataProviderModule.kt
- update calls to get payment methods, place/commit buy orders and send funds to dash wallet
…1131_Buy_Dash_UI_Order_Preview_Info_dialogs_Error_Success_messages

# Conflicts:
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseBuyDashFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseServicesViewModel.kt
#	wallet/src/de/schildbach/wallet/ui/coinbase/CoinBaseWebClientActivity.kt
- update event on EnterAmountFragment.kt -> record event for coinbase flow only
- rollback to using Event wrapper class in Coinbase flow to ensure navigation is only fired once
…baseServicesFragment.kt

- propagate logging of Coinbase events from EnterAmountFragment.kt to CoinbaseBuyDashFragment.kt
@ClaudeHangui
ClaudeHangui requested a review from Syn-McJ February 22, 2022 14:38
@ClaudeHangui
ClaudeHangui changed the base branch from master to feature-coinbase-integration February 22, 2022 14:39
…to feature-coinbase-error-handling

# Conflicts:
#	common/src/main/res/values/colors.xml
…to feature-coinbase-error-handling

# Conflicts:
#	common/src/main/java/org/dash/wallet/common/ui/payment_method_picker/PaymentMethodPicker.kt
#	common/src/main/java/org/dash/wallet/common/util/GenericUtils.java
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/repository/CoinBaseRepository.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/service/CoinBaseServicesApi.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseBuyDashFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseBuyDashOrderReviewFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/ui/CoinbaseServicesFragment.kt
#	integrations/coinbase-integration/src/main/java/org/dash/wallet/integration/coinbase_integration/viewmodels/CoinbaseBuyDashViewModel.kt
#	integrations/coinbase-integration/src/main/res/navigation/nav_coinbase.xml
#	integrations/coinbase-integration/src/main/res/values/strings.xml
#	wallet/src/de/schildbach/wallet/ui/coinbase/CoinBaseWebClientActivity.kt
android:background="@color/divider_color"
app:layout_constraintTop_toBottomOf="@id/coinbase_header_label" />

<ImageView

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a discussion with Ross, he pointed out that this coinbase label is actually an image

@HashEngineering HashEngineering changed the title Feature coinbase error handling Feat(coinbase): error handling Feb 22, 2022
Comment on lines +212 to +215
public static String getLocaleCurrencyCode(){
NumberFormat numberFormat = NumberFormat.getCurrencyInstance(getDeviceLocale());
return numberFormat.getCurrency().getCurrencyCode();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases, this will return a different code than what the app is using.

Examples: VEF (official for Venezuella) instead of VES. Belarus also changed its currency code (older devices have the older code).

The CurrencyInfo class has some functions to handle these cases, though not all. Obsolete (like for Belarus), but not for VEF -> VES.

Guess, we need to check for crashes on KRIP devices.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh I see, will take a look at it now !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HashEngineering updated the implementation of this function as per your suggestions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this fix.


override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding.closeBtn.setOnClickListener { findNavController().navigateUp() }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why, as I mentioned before, we should not use a navigation controller for simple dialogs. This line makes it impossible to reuse this dialog in my story because there is no navigation controller in the wallet module.

Moreover, this dialog doesn't even need to have a separate backing class, we can use AdaptiveDialog with a custom layout.

It's fine for this PR, but I'll have to refactor this a bit to be able to reuse it.

@Syn-McJ Syn-McJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ClaudeHangui would be nice to remove logging from the PaymentMethodPicker and move it down to Coinbase module.


public String getCoinbaseUserWithdrawalRemaining() {
return prefs.getString(PREFS_KEY_COINBASE_USER_WITHDRAWAL_REMAINING, getCoinbaseUserWithdrawalLimitAmount());
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep adding things to this Configuration class which will balloon it sooner or later beyond manageable. I'm thinking we should split it into module-specific configuration classes + a global one in the future.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was wondering the same thing.

The common module doesn't need to know about settings/configuration that are specific to other modules. When we do make a change for module-specific vs global, we must take care not to break or lose any settings.

showSearch = false
) { _, index, dialog ->
dialog.dismiss()
analytics.logEvent(AnalyticsConstants.Coinbase.CHANGE_PAYMENT_METHOD, bundleOf())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the same mistake as before with the EnterAmount fragment. This component should not care about analytics, and it might be used in other integration modules. AnalyticsService should be injected.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a merge error from my side !

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed !

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/steel_gray_50" />
<corners android:radius="14dp" />

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding a whole bunch of drawables for various backgrounds, you could use the rounded_background.xml with a theme, like this:

<View
...
android:background="@drawable/rounded_background"
android:theme="@style/SearchInputBackground"

in styles:

<style name="SearchInputBackground">
    <item name="backgroundColor">@color/gray_40</item>
    <item name="strokeColor">@color/gray_40</item>
    <item name="cornerRadius">8dp</item>
</style>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me try it out !

@Syn-McJ Syn-McJ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

- set new styles for dialog_withdrawal_limit_info.xml
- update UI for dialog_withdrawal_limit_info.xml
- restore implementation for CoinbaseBuyDashFragment.kt & CoinbaseServicesFragment.kt
@HashEngineering
HashEngineering merged commit e285dcf into feature-coinbase-integration Feb 24, 2022
Syn-McJ added a commit that referenced this pull request Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants