Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: improve observe tx bugfixes #1340

Merged
merged 20 commits into from
Jan 14, 2025

Conversation

Syn-McJ
Copy link
Member

@Syn-McJ Syn-McJ commented Jan 10, 2025

Issue being fixed or feature implemented

Some improvements to bugfix-observe-tx PR, see comments

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 Syn-McJ self-assigned this Jan 10, 2025
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
Copy link
Member Author

@Syn-McJ Syn-McJ Jan 10, 2025

Choose a reason for hiding this comment

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

This should ensure support for the latest Android Studio

override val wrappers = listOf(wrapper)

override fun tryInclude(tx: Transaction): Pair<Boolean, TransactionWrapper?> {
if (wrapper.isComplete) {
Copy link
Member Author

Choose a reason for hiding this comment

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

If 5 CrowdNode signup transactions are found, not need to check for more

android:singleLine="true"
android:ellipsize="end"
android:text="John Doe" />
</androidx.constraintlayout.widget.ConstraintLayout>
Copy link
Member Author

Choose a reason for hiding this comment

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

Some UI bugs in the tx confirmation dialog when contacts are involved

fun wrapTransactions(
transactions: Set<Transaction?>,
vararg wrapperFactories: TransactionWrapperFactory
): Collection<TransactionWrapper> {
wrapperFactories.sortByDescending { it.maxTransactions }
Copy link
Member Author

Choose a reason for hiding this comment

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

CoinJoin wrappers will have a much higher hit rate for including transactions, so checking them first

}
added = true
break
Copy link
Member Author

Choose a reason for hiding this comment

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

If one wrapper has tx included, no need to check more

log.info("NMA-243: Exception thrown obtaining Locale information: ", e)
if (selectedCurrencyCode == null) {
setDefaultCurrency()
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to a separate utility class

contacts.data?.forEach { result ->
contactsByIdentity[result.dashPayProfile.userId] = result.dashPayProfile
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Fetching contacts/metadata in parallel

tx.txId == txInGroup.txId
} != null
val items = _transactions.value!!.toMutableMap()
val txByHash = this.txByHash.toMutableMap()
Copy link
Member Author

Choose a reason for hiding this comment

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

Keeping exposed fields unmutable and creating mutable collections when modifying should help to avoid concurrent modification errors

override fun onItemClicked(view: View, usernameSearchResult: UsernameSearchResult) {
handleString(usernameSearchResult.fromContactRequest!!.userId)
handleContactId(usernameSearchResult.fromContactRequest!!.userId)
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes an error with payment to a contact from send tab

@@ -130,7 +130,7 @@ class TransactionDetailsDialogFragment : OffsetDialogFragment(R.layout.transacti
private fun initiateTransactionBinder(tx: Transaction, dashPayProfile: DashPayProfile?) {
contentBinding = TransactionResultContentBinding.bind(binding.transactionResultContainer)
transactionResultViewBinder.bind(tx, dashPayProfile)
contentBinding.viewOnExplorer.setOnClickListener { viewOnBlockExplorer() }
contentBinding.openExplorerCard.setOnClickListener { viewOnBlockExplorer() }
Copy link
Member Author

Choose a reason for hiding this comment

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

Fixes "explorer" row not being properly clickable

@@ -51,7 +52,8 @@ open class CrowdNodeBlockchainApi @Inject constructor(

suspend fun topUpAddress(accountAddress: Address, amount: Coin, emptyWallet: Boolean = false): Transaction {
val topUpTx = paymentService.sendCoins(accountAddress, amount, null, emptyWallet)
return walletData.observeTransactions(true, LockedTransaction(topUpTx.txId)).first()
topUpTx.waitToMatchFilters(LockedTransaction())
return topUpTx
Copy link
Member Author

Choose a reason for hiding this comment

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

Somewhat different pattern here: if we already have a transaction, observe itself. If we don't observe the wallet.
The rest of CoinJoin transactions don't need this because we're waiting for response and not for them to become locked.

@Syn-McJ Syn-McJ merged commit 9d9dfe2 into bugfix-observe-tx Jan 14, 2025
3 checks passed
@Syn-McJ Syn-McJ deleted the bugfix-observe-tx-improvements branch January 14, 2025 04:27
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.

2 participants