Skip to content

feat: buy dash from coinbase data-layer - #843

Merged
HashEngineering merged 76 commits into
feature-coinbase-integrationfrom
feature-buy-dash-data
Jan 19, 2022
Merged

HashEngineering merged 76 commits into
feature-coinbase-integrationfrom
feature-buy-dash-data

Conversation

@ClaudeHangui

@ClaudeHangui ClaudeHangui commented Dec 23, 2021 •

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

This task focuses on providing data needed by the UI to perform the buy dash from coinbase flow:

  • Get the current user's active payment methods
  • Purchase order on coinbase (buy order)
  • Completion of a purchase (commit order)
  • Sending funds to dash wallet (send transactions)

Related PR's and Dependencies

Screenshots / Videos

How Has This Been Tested?

  • QA (Mobile Team)

Checklist:

  • 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 5 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
@ClaudeHangui
ClaudeHangui changed the base branch from master to feature-coinbase-integration December 23, 2021 12:23
ClaudeHangui and others added 4 commits December 23, 2021 12:26
…to feature-buy-dash-data

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

@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.

Looks fine to me, but shouldn't there be some examples of using these endpoints? I know we need UI for getting actual values the user has input, but until then some predefined mock values could be used.

@ClaudeHangui

Copy link
Copy Markdown
Contributor Author

Looks fine to me, but shouldn't there be some examples of using these endpoints? I know we need UI for getting actual values the user has input, but until then some predefined mock values could be used.

You mean provide unit tests and set default values for the data classes ?

Syn-McJ and others added 16 commits December 25, 2021 14:26
…_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
…to feature-buy-dash-data

# Conflicts:
#	.gitignore
#	common/src/main/java/org/dash/wallet/common/Configuration.java
#	common/src/main/res/values/styles.xml
#	features/exploredash/src/androidTest/java/org/dash/wallet/features/exploredash/CoroutineDispatcherRule.kt
#	features/exploredash/src/androidTest/java/org/dash/wallet/features/exploredash/ExampleInstrumentedTest.kt
#	features/exploredash/src/androidTest/java/org/dash/wallet/features/exploredash/TestUtils.kt
#	features/exploredash/src/androidTest/java/org/dash/wallet/features/exploredash/repository/CoinBaseRepositoryTest.kt
#	features/exploredash/src/androidTest/java/org/dash/wallet/features/exploredash/viewmodels/CoinbaseServicesViewModelTest.kt
- redirect to coinbase portal upon successful login via coinbase
- redirect to wallet home screen after successful transfer of dash wallet
- set min_amount and send_limit_period for coinbase client
Comment on lines +24 to +25
const val TEMP_ACCESS_TOKEN = "133848085c006dd1ec9b591c859506d6c2e31598d3b7c5e8c197da600687417d"
const val TEMP_REFRESH_TOKEN = "d28ae95beb4c5149644ee946e100479206b7204559e5944bc5ab151389a4279c"

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.

should these be in the code, or be taken from services.properties?

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.

these constants as well will be removed. They were used for testing purposes, forgot to remove it

Comment on lines +55 to +62
/*
val refreshToken = if (userPreferences.hasTempTokenBeenUsed) {
userPreferences.lastCoinbaseRefreshToken
} else {
userPreferences.hasTempTokenBeenUsed = true
TEMP_REFRESH_TOKEN
}
*/

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.

should this still be here?

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.

ahh yes, this portion is depreciated. will remove 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.

Great work, there are some minor fixes needed with AmountView and styles.

Comment thread .gitignore Outdated
output-metadata.json
service.properties
wallet/schemas/*/*.json
wallet/schemas/*/*.json No newline at end of file

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.

I thought we've decided not to remove those from git

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.

This may have been from another PR that was merged into this PR.

class FancyAlertDialog : DialogFragment() {
private val lockScreenViewModel by activityViewModels<LockScreenViewModel>()
private val sharedViewModel by activityViewModels<FancyAlertDialogViewModel>()
var onFancyAlertButtonsClickListener: FancyAlertButtonsClickListener? = null

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.

I don't get why do we need both sharedViewModel and a click listener for observing dialog actions. It's probably better to get rid of the ViewModel at some point as it is misused here. (No action needed atm)

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.

I agree with removing FancyAlertDialogViewModel and use lamda's instead for the click listeners as a separate action.

set(value) {
field = value
binding.inputCurrencyToggle.isVisible = value
binding.resultCurrencyToggle.isVisible = value

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.

If this property is set to True and updateDashSymbols isn't called, both currency toggles will be visible. dashToFiat has to be considered here before setting visibility.

Comment thread common/src/main/res/values/styles.xml Outdated
<item name="android:textColor">@color/dash_blue</item>
</style>

<style name="Body2.red_300">

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.

Styling names don't match the rest. Let's keep it consistent to avoid duplicates. This should be Body2.Red300, as well as Headline5.Bold.Red previously. Also, if we have a style with red_300 color, it should be either .Red or .Red300, but not both.

Comment thread common/src/main/res/values/styles.xml Outdated
<item name="android:lineSpacingExtra">3sp</item>
</style>

<style name="Caption.dashBlue">

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.

Just .Blue is fine. dash_blue is the default blue color.

setOrHideIfEmpty(binding.coinbaseDialogPositiveButton, "positive_text")
setOrHideIfEmpty(binding.coinbaseDialogNegativeButton, "negative_text")
lockScreenViewModel.activatingLockScreen.observe(this){
Log.e(this::class.java.simpleName, "Closing dialog")

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.

Do we really need these error logs in the logcat? I understand if it is used for development purposes, but it should be cleaned up afterward. Having random red messages in logcat that are not actually errors is confusing.

/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {

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 have SingleLiveEvent, can it serve the same purpose?

@ClaudeHangui

Copy link
Copy Markdown
Contributor Author

there were some work from Hadia that I forgot to update accordingly, working on the fixes

@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.

Looks good

@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.

Looks great

@HashEngineering
HashEngineering merged commit b6d6de0 into feature-coinbase-integration Jan 19, 2022
@HashEngineering
HashEngineering deleted the feature-buy-dash-data branch May 19, 2022 14:21
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