Skip to content

fix: handle crash and error message for buy dash above withdrawal limit - #902

Merged
HashEngineering merged 5 commits into
feature-coinbase-integrationfrom
bugfix-coinbase-error-handling
Mar 1, 2022
Merged

HashEngineering merged 5 commits into
feature-coinbase-integrationfrom
bugfix-coinbase-error-handling

Conversation

@ClaudeHangui

@ClaudeHangui ClaudeHangui commented Feb 25, 2022 •

Copy link
Copy Markdown
Contributor
  • remove unused coinbase preferences
  • display appropriate error message when dash successfully purchased could not be sent to a wallet
  • handle crash caused by ArithmeticException after user input amount to purchase

Issue being fixed or feature implemented

This is an improvement for NMA-1165
Besides the crash found during testing, there has been an update in the AC: we need to provide the exact error message the Coinbase API sends in case the dash purchased could not be successfully sent to a wallet. Here is an example of the error message :
Cannot send this amount without going over application limit (limit 5.00 USD, 0.19 USD remaining)

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

- display appropriate error message for input amount greater than withdrawal limit
- handle crash caused by ArithmeticException after user input amount to be sent
@ClaudeHangui ClaudeHangui changed the title fix: remove unused coinbase preferences fix: handle crash and error message for buy dash above withdrawal limit Feb 25, 2022

@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

…input amount greater than withdrawal limit

- reproduce implementation for Convert-Crypto flow
- remove unused test files from explore-dash module plus duplicate CoinBaseRepositoryTest.kt
_transactionCompleted.value = TransactionState(true, null)
}
else -> _transactionCompleted.value = false
400 -> {

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.

For Coinbase's 40x responses, it appears the safeApiCall()sometimes sends ResponseResource of type Success, with an appropriate error body (if any) which is mainly why we couldn't see the api error message sent by coinbase

_transactionCompleted.value = TransactionState(true, null)
}
else -> _transactionCompleted.value = false
400 -> {

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.

We needed to replicate this behavior for the Buy Swap flow since the end result expected its the same when transferring dash to wallet

@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. I have left a comment on return types to consider.

suspend fun placeBuyOrder(placeBuyOrderParams: PlaceBuyOrderParams): ResponseResource<PlaceBuyOrderUIModel>
suspend fun commitBuyOrder(buyOrderId: String): ResponseResource<CommitBuyOrderUIModel>
suspend fun sendFundsToWallet(sendTransactionToWalletParams: SendTransactionToWalletParams): ResponseResource<Int>
suspend fun sendFundsToWallet(sendTransactionToWalletParams: SendTransactionToWalletParams): ResponseResource<Response<SendTransactionToWalletResponse?>>

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.

The response type of this method seems somewhat convoluted. There are 3 nested "Responses" of some kind.

When you have a suspend method, there isn't really a reason to use a class like ResponseResource in my opinion. The exception is propagated, so you have response/error functionality already, just need to try/catch it. Loading object isn't used in Coinbase right now, and the loading state can be implemented in other ways.

@HashEngineering
HashEngineering merged commit 30ae4e8 into feature-coinbase-integration Mar 1, 2022
@Syn-McJ
Syn-McJ deleted the bugfix-coinbase-error-handling branch March 16, 2022 05:09
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.

3 participants