Skip to content

Nma 1067 custodial swaps sell dash - #926

Merged
HashEngineering merged 16 commits into
feature-coinbase-integrationfrom
NMA-1067_Custodial_Swaps_Sell_Dash
Apr 1, 2022
Merged

Nma 1067 custodial swaps sell dash#926
HashEngineering merged 16 commits into
feature-coinbase-integrationfrom
NMA-1067_Custodial_Swaps_Sell_Dash

Conversation

@hadia

@hadia hadia commented Mar 31, 2022

Copy link
Copy Markdown
Contributor

As a user who has a Coinbase account I would like to be able to swap my dash in my Dash Wallet to another crypto into my Coinbase account.

Issue being fixed or feature implemented

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

Comment on lines +24 to +31
interface SendPaymentService {
suspend fun sendCoins(
address: Address,
amount: Coin,
constrainInputsTo: Address? = null,
emptyWallet: Boolean = false
): Transaction
}

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.

@Syn-McJ Didn't also make a similar service? or is this the same one?

@Syn-McJ Syn-McJ Mar 31, 2022

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.

It's the same one as I understand, Hadia has asked me about sending coins and I have referenced my solution.

@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, but I have some comments/questions. I'm mostly concerned with AlertDialog that is going to stick on top of the lock screen

}

private fun show2FADialog() {
val builder: AlertDialog.Builder = android.app.AlertDialog.Builder(requireContext())

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.

AlertDialog will not be dismissed automatically when the lock screen shows up. Can this be implemented with a DialogFragment subclass instead?

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 this its just temp code and will be replaced in with the new 2FA Dialog

}

private fun show2FADialog() {
val builder: AlertDialog.Builder = android.app.AlertDialog.Builder(requireContext())

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.

Same point about AlertDialog (see above)

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 this its just temp code and will be replaced in with the new 2FA Dialog

binding.youWillReceiveValue.isVisible = hasBalance
if (hasBalance) {
binding.youWillReceiveValue.text = context?.getString(R.string.you_will_receive_dash, dashFormat.format(balance).toString())
binding.youWillReceiveValue.text = context?.getString(

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.

You can use requireContext here.

Suggested change
binding.youWillReceiveValue.text = context?.getString(
binding.youWillReceiveValue.text = requireContext().getString(

Comment on lines +24 to +31
interface SendPaymentService {
suspend fun sendCoins(
address: Address,
amount: Coin,
constrainInputsTo: Address? = null,
emptyWallet: Boolean = false
): Transaction
}

@Syn-McJ Syn-McJ Mar 31, 2022

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.

It's the same one as I understand, Hadia has asked me about sending coins and I have referenced my solution.

}

private fun getFaitAmount(balance: String, currencyCode: String): Fiat? {
private fun getFaitAmount(balance: String, currencyCode: String): Pair<Fiat?, Coin?>? {

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.

Typo in the name I think

viewModel.selectedCryptoCurrencyAccount.value?.let { userAccountData ->


val cleanedValue =

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 method (setAmountValue) seems quite convoluted, and it's all just for getting a clean value. Maybe it's worth to think about how to simplify it / extract some parts to separate methods

fun setOnSwapDashFromToCryptoClicked(dashToCrypto: Boolean) {
if (dashToCrypto) {
if (walletDataProvider.getWalletBalance().isZero) {
_userDashAccountEmptyError.value = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

since _userDashAccountEmptyError.value = true always applies, I think you're better off using SingleLiveEvent<Unit>

import java.math.RoundingMode
import javax.inject.Inject

@ExperimentalCoroutinesApi

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

you might as well add this annotation in the CoinbaseConvertCryptoFragment class

private val walletDataProvider: WalletDataProvider
) : ViewModel() {

val dashFormat = MonetaryFormat().withLocale(GenericUtils.getDeviceLocale())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This property could be private if used only within this class


private val _dashToCrypto = MutableLiveData<Boolean>()
val dashToCrypto: LiveData<Boolean>
get() = this._dashToCrypto

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is there a specific reason for appending this keyword in some of the properties used within this class ?!
I think you can get rid of it

_dashToCrypto.value = dashToCrypto
}

fun clear() { _selectedCryptoCurrencyAccount.value = null }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this function is to be called when the view is no more used, you might as well call it directly in onCleared() function of the VM which is automatically called when fragment is destroyed

@ClaudeHangui ClaudeHangui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Works for me !
slight improvements though could be made in some view models

@HashEngineering
HashEngineering merged commit 8cb7505 into feature-coinbase-integration Apr 1, 2022
@HashEngineering
HashEngineering deleted the NMA-1067_Custodial_Swaps_Sell_Dash branch July 20, 2022 23:20
bfoss765 added a commit that referenced this pull request Aug 11, 2026
Built from platform `integration/v41-keystore-qa5` @ 7c495eab76. Three
changes over v41int19:

* **Pooled asset-lock funding** (dashpay/platform#4350). An invitation,
  identity registration or top-up now funds from the union of the BIP44 and
  BIP32 accounts at the given index plus every DashPay contact-receiving
  account, with change back to BIP44 — the same set the send path has pooled
  since #4329. A lock no longer needs its whole amount sitting in one
  account, so the sweep-then-lock hop (an extra on-chain transaction, an
  extra fee, and a reused transparent address) is gone. Reservation release
  after a rejected broadcast now reaches every contributing account under
  the build's owner token, and the funding-transaction lookup that gates the
  proof wait searches all four account families — a lock funded entirely out
  of BIP32 or a contact account was previously invisible to it. Shielded
  funding and CoinJoin funding are unchanged: both still draw from the one
  account the caller names.

  Carries the rust-dashcore pin from 8f26456b to d44d241d, which is that
  commit plus exactly one — dashpay/rust-dashcore#935, the pooled builder
  this depends on.

* **Contact watch-only records no longer define the persisted transaction
  row** (#926 completion). A payment TO a contact stopped being persisted as
  incoming, and the contact's own coins stopped entering `txos`.

* Pre-existing clippy/rustfmt debt on the qa5 line cleared, so the lint gate
  is green again.

Verified before publishing: platform-wallet 637 Rust tests,
platform-wallet-ffi 254, rs-unified-sdk-jni 38, Kotlin SDK 436 unit tests,
`cargo clippy --lib --tests -- -D warnings` and `cargo fmt --check` clean,
and both JNI libraries verified (241 exports, 16 KB-aligned LOAD segments,
arm64-v8a + x86_64).

Here: `:wallet:compile_testNet3DebugKotlin` plus the full unit suite — 1705
tests, 0 failures. No APK built and nothing installed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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