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

Add '0x' prefix to transactionHash in WC send transaction response #7578

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ android {
compileSdk compile_sdk_version
minSdkVersion min_sdk_version
targetSdkVersion compile_sdk_version
versionCode 110
versionName "0.39.0"
versionCode 111
versionName "0.40.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

ksp {
Expand Down
10 changes: 3 additions & 7 deletions app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import io.horizontalsystems.bankwallet.core.managers.AccountCleaner
import io.horizontalsystems.bankwallet.core.managers.AccountManager
import io.horizontalsystems.bankwallet.core.managers.AdapterManager
import io.horizontalsystems.bankwallet.core.managers.AppVersionManager
import io.horizontalsystems.bankwallet.core.managers.BackgroundStateChangeListener
import io.horizontalsystems.bankwallet.core.managers.BackupManager
import io.horizontalsystems.bankwallet.core.managers.BalanceHiddenManager
import io.horizontalsystems.bankwallet.core.managers.BaseTokenManager
Expand Down Expand Up @@ -141,7 +140,6 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory {
lateinit var btcBlockchainManager: BtcBlockchainManager
lateinit var wordsManager: WordsManager
lateinit var networkManager: INetworkManager
lateinit var backgroundStateChangeListener: BackgroundStateChangeListener
lateinit var appConfigProvider: AppConfigProvider
lateinit var adapterManager: IAdapterManager
lateinit var transactionAdapterManager: TransactionAdapterManager
Expand Down Expand Up @@ -358,13 +356,11 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory {
pinComponent = PinComponent(
pinSettingsStorage = pinSettingsStorage,
userManager = userManager,
pinDbStorage = PinDbStorage(appDatabase.pinDao())
pinDbStorage = PinDbStorage(appDatabase.pinDao()),
backgroundManager = backgroundManager
)

statsManager = StatsManager(appDatabase.statsDao(), localStorage, marketKit, appConfigProvider)
backgroundStateChangeListener = BackgroundStateChangeListener(pinComponent, statsManager).apply {
backgroundManager.registerListener(this)
}
statsManager = StatsManager(appDatabase.statsDao(), localStorage, marketKit, appConfigProvider, backgroundManager)

rateAppManager = RateAppManager(walletManager, adapterManager, localStorage)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import io.horizontalsystems.bitcoincore.storage.FullTransaction
import io.horizontalsystems.bitcoincore.storage.UnspentOutput
import io.horizontalsystems.bitcoincore.storage.UnspentOutputInfo
import io.horizontalsystems.core.BackgroundManager
import io.horizontalsystems.core.BackgroundManagerState
import io.horizontalsystems.hodler.HodlerOutputData
import io.horizontalsystems.hodler.HodlerPlugin
import io.horizontalsystems.marketkit.models.Token
Expand All @@ -40,35 +41,27 @@ import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.cancel
import kotlinx.coroutines.launch
import java.math.BigDecimal
import java.math.RoundingMode
import java.util.Date

abstract class BitcoinBaseAdapter(
open val kit: AbstractKit,
open val syncMode: BitcoinCore.SyncMode,
backgroundManager: BackgroundManager,
private val backgroundManager: BackgroundManager,
val wallet: Wallet,
private val confirmationsThreshold: Int,
protected val decimal: Int = 8
) : IAdapter, ITransactionsAdapter, IBalanceAdapter, IReceiveAdapter, BackgroundManager.Listener {
) : IAdapter, ITransactionsAdapter, IBalanceAdapter, IReceiveAdapter {

init {
backgroundManager.registerListener(this)
}
private val scope = CoroutineScope(Dispatchers.Default)

abstract val satoshisInBitcoin: BigDecimal

override fun willEnterForeground() {
super.willEnterForeground()
kit.onEnterForeground()
}

override fun didEnterBackground() {
super.didEnterBackground()
kit.onEnterBackground()
}

//
// Adapter implementation
//
Expand Down Expand Up @@ -173,10 +166,12 @@ abstract class BitcoinBaseAdapter(

override fun start() {
kit.start()
subscribeToEvents()
}

override fun stop() {
kit.stop()
scope.cancel()
}

override fun refresh() {
Expand Down Expand Up @@ -215,6 +210,24 @@ abstract class BitcoinBaseAdapter(
}
}

private fun subscribeToEvents() {
scope.launch {
backgroundManager.stateFlow.collect { state ->
when (state) {
BackgroundManagerState.EnterForeground -> {
kit.onEnterForeground()
}
BackgroundManagerState.EnterBackground -> {
kit.onEnterBackground()
}
BackgroundManagerState.AllActivitiesDestroyed -> {

}
}
}
}
}

override fun getRawTransaction(transactionHash: String): String? {
return kit.getRawTransaction(transactionHash)
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ package io.horizontalsystems.bankwallet.core.managers

import io.horizontalsystems.bankwallet.core.ILocalStorage
import io.horizontalsystems.core.BackgroundManager
import io.horizontalsystems.core.BackgroundManagerState
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch

class BalanceHiddenManager(
private val localStorage: ILocalStorage,
backgroundManager: BackgroundManager,
): BackgroundManager.Listener {
) {
val balanceHidden: Boolean
get() = localStorage.balanceHidden

Expand All @@ -20,9 +24,16 @@ class BalanceHiddenManager(

private val _balanceHiddenFlow = MutableStateFlow(localStorage.balanceHidden)
val balanceHiddenFlow = _balanceHiddenFlow.asStateFlow()
private val scope = CoroutineScope(Dispatchers.Default)

init {
backgroundManager.registerListener(this)
scope.launch {
backgroundManager.stateFlow.collect { state ->
if (state == BackgroundManagerState.EnterBackground && balanceAutoHide) {
setBalanceHidden(true)
}
}
}

if (balanceAutoHide) {
setBalanceHidden(true)
Expand All @@ -42,12 +53,6 @@ class BalanceHiddenManager(
}
}

override fun didEnterBackground() {
if (balanceAutoHide) {
setBalanceHidden(true)
}
}

private fun setBalanceHidden(hidden: Boolean) {
localStorage.balanceHidden = hidden
_balanceHiddenFlow.update { localStorage.balanceHidden }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@ import android.net.NetworkCapabilities
import android.net.NetworkRequest
import io.horizontalsystems.bankwallet.core.App
import io.horizontalsystems.core.BackgroundManager
import io.horizontalsystems.core.BackgroundManagerState
import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch


class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundManager.Listener {
class ConnectivityManager(backgroundManager: BackgroundManager) {

private val connectivityManager: ConnectivityManager by lazy {
App.instance.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}

private val scope = CoroutineScope(Dispatchers.Default)
private val _networkAvailabilityFlow =
MutableSharedFlow<Boolean>(extraBufferCapacity = 1, onBufferOverflow = BufferOverflow.DROP_OLDEST)

Expand All @@ -32,11 +36,24 @@ class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundMana
private var hasConnection = false

init {
backgroundManager.registerListener(this)
scope.launch {
backgroundManager.stateFlow.collect { state ->
when (state) {
BackgroundManagerState.EnterForeground -> {
willEnterForeground()
}
BackgroundManagerState.EnterBackground -> {
didEnterBackground()
}
BackgroundManagerState.AllActivitiesDestroyed -> {
//do nothing
}
}
}
}
}

override fun willEnterForeground() {
super.willEnterForeground()
private fun willEnterForeground() {
setInitialValues()
try {
connectivityManager.unregisterNetworkCallback(callback)
Expand All @@ -46,8 +63,7 @@ class ConnectivityManager(backgroundManager: BackgroundManager) : BackgroundMana
connectivityManager.registerNetworkCallback(NetworkRequest.Builder().build(), callback)
}

override fun didEnterBackground() {
super.didEnterBackground()
private fun didEnterBackground() {
try {
connectivityManager.unregisterNetworkCallback(callback)
} catch (e: Exception) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import io.horizontalsystems.bankwallet.entities.Currency
import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.launch

class CurrencyManager(private val localStorage: ILocalStorage, private val appConfigProvider: AppConfigProvider) {

private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val scope = CoroutineScope(Dispatchers.Default)

private val _baseCurrencyUpdatedFlow: MutableSharedFlow<Unit> = MutableSharedFlow()
val baseCurrencyUpdatedFlow: SharedFlow<Unit> = _baseCurrencyUpdatedFlow.asSharedFlow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import io.horizontalsystems.bankwallet.core.supportedNftTypes
import io.horizontalsystems.bankwallet.entities.Account
import io.horizontalsystems.bankwallet.entities.AccountType
import io.horizontalsystems.core.BackgroundManager
import io.horizontalsystems.core.BackgroundManagerState
import io.horizontalsystems.erc20kit.core.Erc20Kit
import io.horizontalsystems.ethereumkit.core.EthereumKit
import io.horizontalsystems.ethereumkit.core.signer.Signer
Expand All @@ -30,20 +31,20 @@ import io.reactivex.subjects.BehaviorSubject
import io.reactivex.subjects.PublishSubject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.launch
import kotlinx.coroutines.rx2.asFlow
import java.net.URI

class EvmKitManager(
val chain: Chain,
backgroundManager: BackgroundManager,
private val backgroundManager: BackgroundManager,
private val syncSourceManager: EvmSyncSourceManager
) : BackgroundManager.Listener {
) {
private val coroutineScope = CoroutineScope(Dispatchers.Default)
private var job: Job? = null

init {
backgroundManager.registerListener(this)

coroutineScope.launch {
syncSourceManager.syncSourceObservable.asFlow().collect { blockchain ->
handleUpdateNetwork(blockchain)
Expand Down Expand Up @@ -91,6 +92,7 @@ class EvmKitManager(
evmKitWrapper = createKitInstance(accountType, account, blockchainType)
useCount = 0
currentAccount = account
subscribeToEvents()
}

useCount++
Expand Down Expand Up @@ -178,25 +180,26 @@ class EvmKitManager(
}
}

private fun subscribeToEvents(){
job = coroutineScope.launch {
backgroundManager.stateFlow.collect { state ->
if (state == BackgroundManagerState.EnterForeground) {
evmKitWrapper?.evmKit?.let { kit ->
Handler(Looper.getMainLooper()).postDelayed({
kit.refresh()
}, 1000)
}
}
}
}
}

private fun stopEvmKit() {
job?.cancel()
evmKitWrapper?.evmKit?.stop()
evmKitWrapper = null
currentAccount = null
}

//
// BackgroundManager.Listener
//

override fun willEnterForeground() {
this.evmKitWrapper?.evmKit?.let { kit ->
Handler(Looper.getMainLooper()).postDelayed({
kit.refresh()
}, 1000)
}
}

override fun didEnterBackground() = Unit
}

val RpcSource.uris: List<URI>
Expand Down
Loading
Loading