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
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/manual_distribution.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ jobs:
GC_STORAGE_SERVICE_ACCOUNT_KEY_JSON: ${{secrets.GC_STORAGE_SERVICE_ACCOUNT_KEY_JSON}}

- name: Test
run: bundle exec fastlane test flavor:"${{ github.event.inputs.flavor }}" type:"${{ github.event.inputs.type }}" versioncode:"${{ env.build_number }}" storepass:"${{ secrets.SIGNING_STORE_PASS }}"
run: bundle exec fastlane test flavor:"" type:"debug"

- name: Build and Firebase Distribution
run: bundle exec fastlane build_distribute flavor:"${{ github.event.inputs.flavor }}" type:"${{ github.event.inputs.type }}" versioncode:"${{ env.build_number }}" storepass:"${{ secrets.SIGNING_STORE_PASS }}" comment:"${{ github.event.inputs.taskID }}" appid:"${{ env.firebase_app_id }}" testgroup:"qa"
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
kotlin_version = '1.9.23'
kotlin_version = '1.9.24'
coroutinesVersion = '1.6.4'
ok_http_version = '4.9.1'
dashjVersion = '21.1.5-SNAPSHOT'
Expand Down Expand Up @@ -52,10 +52,10 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:8.7.3'
classpath 'com.google.gms:google-services:4.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.5.2' // Crashlytics
classpath 'com.google.firebase:firebase-crashlytics-gradle:3.0.2' // Crashlytics
classpath "com.google.dagger:hilt-android-gradle-plugin:$hiltVersion"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$navigationVersion"
classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
Expand All @@ -64,7 +64,7 @@ buildscript {
}

plugins {
id 'com.google.devtools.ksp' version '1.9.23-1.0.19' apply false
id 'com.google.devtools.ksp' version '1.9.24-1.0.20' apply false
}

allprojects {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.11"
kotlinCompilerExtensionVersion = "1.5.14"
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
kotlinOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,4 @@ class TransactionComparator: Comparator<Transaction> {

return tx1.txId.compareTo(tx2.txId)
}
}

class TransactionWrapperComparator: Comparator<TransactionWrapper> {
private val txComparator = TransactionComparator()

override fun compare(wrapper1: TransactionWrapper, wrapper2: TransactionWrapper): Int {
return txComparator.compare(wrapper1.transactions.last(), wrapper2.transactions.last())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

@file:OptIn(FlowPreview::class)

package org.dash.wallet.common.transactions

import android.util.Log
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map
Expand Down Expand Up @@ -135,12 +139,11 @@ fun Flow<Transaction>.batchAndFilterUpdates(timeInterval: Long = 500): Flow<List
// Update the latest transaction for the hash
latestTransactions[transaction.txId] = transaction
}
.sample(timeInterval) // Emit events every 500ms
.sample(timeInterval) // Emit events every [timeInterval]
.map {
// Collect the latest transactions
latestTransactions.values.toList().also {
latestTransactions.clear() // Clear after collecting
latestTransactions.clear()
}
}
.filter { it.isNotEmpty() } // Only emit non-empty lists
}
.filter { it.isNotEmpty() }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@
package org.dash.wallet.common.transactions

import org.bitcoinj.core.Coin
import org.bitcoinj.core.Sha256Hash
import org.bitcoinj.core.Transaction
import org.bitcoinj.core.TransactionBag
import java.time.LocalDate

interface TransactionWrapper {
val transactions: Set<Transaction>
val id: String
val transactions: HashMap<Sha256Hash, Transaction>
val groupDate: LocalDate
fun tryInclude(tx: Transaction): Boolean
fun getValue(bag: TransactionBag): Coin
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.dash.wallet.common.transactions
import org.bitcoinj.core.Transaction

interface TransactionWrapperFactory {
fun tryInclude(tx: Transaction): Pair<Boolean, TransactionWrapper?>
val maxTransactions: Long
val wrappers: List<TransactionWrapper>
fun tryInclude(tx: Transaction): Pair<Boolean, TransactionWrapper?>
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,5 +297,6 @@ class EnterAmountFragment : Fragment(R.layout.fragment_enter_amount) {

fun setMessage(message: String) {
binding.messageText.text = message
binding.messageText.isVisible = message.isNotEmpty()
}
}
1 change: 1 addition & 0 deletions common/src/main/res/layout/fragment_enter_amount.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
android:layout_marginHorizontal="20dp"
android:paddingHorizontal="8dp"
android:gravity="center_horizontal"
android:visibility="gone"
android:background="@drawable/gray_button_background"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down
6 changes: 6 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
android.enableJetifier=true
android.useAndroidX=true
org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=true
org.gradle.parallel=true
kotlin.incremental=true
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=false
android.nonFinalResIds=false
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#Mon Oct 02 18:25:36 ICT 2023
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
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
zipStoreBase=GRADLE_USER_HOME
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

zipStorePath=wrapper/dists
Loading
Loading