[#944] Adopt SDK version 2.0.0 with SbS included

* [#944] Adopt SDK version with SbS included

- This supposes to fail in the build until the proper SDK version is consumed
- Tested via included builds

* Adopt latest SDK changes

* Adopt changed TransactionOverview API

* Switch to latest v2.0.0-rc.2

* Fix transaction history test fixture

* Adopt latest SDK snapshot version

* Switch to latest production Zcash SDK version
This commit is contained in:
Honza Rychnovský 2023-09-27 08:52:31 +02:00 committed by GitHub
parent c61645a34f
commit 9ec0de1729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 46 additions and 19 deletions

View File

@ -153,7 +153,7 @@ PLAY_APP_UPDATE_VERSION=2.0.1
PLAY_APP_UPDATE_KTX_VERSION=2.0.1 PLAY_APP_UPDATE_KTX_VERSION=2.0.1
ZCASH_ANDROID_WALLET_PLUGINS_VERSION=1.0.0 ZCASH_ANDROID_WALLET_PLUGINS_VERSION=1.0.0
ZCASH_BIP39_VERSION=1.0.5 ZCASH_BIP39_VERSION=1.0.5
ZCASH_SDK_VERSION=1.20.0-beta01 ZCASH_SDK_VERSION=2.0.0
ZXING_VERSION=3.5.1 ZXING_VERSION=3.5.1

View File

@ -1,5 +1,6 @@
package cash.z.ecc.sdk.fixture package cash.z.ecc.sdk.fixture
import cash.z.ecc.android.sdk.WalletInitMode
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.PersistableWallet import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.android.sdk.model.SeedPhrase import cash.z.ecc.android.sdk.model.SeedPhrase
@ -14,9 +15,12 @@ object PersistableWalletFixture {
val SEED_PHRASE = SeedPhraseFixture.new() val SEED_PHRASE = SeedPhraseFixture.new()
val WALLET_INIT_MODE = WalletInitMode.ExistingWallet
fun new( fun new(
network: ZcashNetwork = NETWORK, network: ZcashNetwork = NETWORK,
birthday: BlockHeight = BIRTHDAY, birthday: BlockHeight = BIRTHDAY,
seedPhrase: SeedPhrase = SEED_PHRASE seedPhrase: SeedPhrase = SEED_PHRASE,
) = PersistableWallet(network, birthday, seedPhrase) walletInitMode: WalletInitMode = WALLET_INIT_MODE
) = PersistableWallet(network, birthday, seedPhrase, walletInitMode)
} }

View File

@ -2,7 +2,7 @@ package co.electriccoin.zcash.ui.fixture
import cash.z.ecc.android.sdk.CloseableSynchronizer import cash.z.ecc.android.sdk.CloseableSynchronizer
import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.block.CompactBlockProcessor import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor
import cash.z.ecc.android.sdk.model.Account import cash.z.ecc.android.sdk.model.Account
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.PercentDecimal
@ -126,7 +126,7 @@ internal class MockSynchronizer : CloseableSynchronizer {
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
} }
override suspend fun rewindToNearestHeight(height: BlockHeight, alsoClearBlockCache: Boolean) { override suspend fun rewindToNearestHeight(height: BlockHeight) {
error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.") error("Intentionally not implemented in ${MockSynchronizer::class.simpleName} implementation.")
} }

View File

@ -8,9 +8,9 @@ import kotlinx.collections.immutable.persistentListOf
internal object TransactionHistorySyncStateFixture { internal object TransactionHistorySyncStateFixture {
val TRANSACTIONS = persistentListOf( val TRANSACTIONS = persistentListOf(
TransactionOverviewFixture.new(id = 0), TransactionOverviewFixture.new(),
TransactionOverviewFixture.new(id = 1), TransactionOverviewFixture.new(),
TransactionOverviewFixture.new(id = 2) TransactionOverviewFixture.new()
) )
val STATE = TransactionHistorySyncState.Syncing(TRANSACTIONS) val STATE = TransactionHistorySyncState.Syncing(TRANSACTIONS)

View File

@ -20,7 +20,10 @@ private val lazy = LazyWithArgument<Context, WalletCoordinator> {
emitAll(EncryptedPreferenceKeys.PERSISTABLE_WALLET.observe(encryptedPreferenceProvider)) emitAll(EncryptedPreferenceKeys.PERSISTABLE_WALLET.observe(encryptedPreferenceProvider))
} }
WalletCoordinator(it, persistableWallet) WalletCoordinator(
context = it,
persistableWallet = persistableWallet
)
} }
fun WalletCoordinator.Companion.getInstance(context: Context) = lazy.getInstance(context) fun WalletCoordinator.Companion.getInstance(context: Context) = lazy.getInstance(context)

View File

@ -1,7 +1,7 @@
package co.electriccoin.zcash.ui.fixture package co.electriccoin.zcash.ui.fixture
import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.block.CompactBlockProcessor import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor
import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.PercentDecimal
import cash.z.ecc.android.sdk.model.WalletBalance import cash.z.ecc.android.sdk.model.WalletBalance
import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.Zatoshi
@ -22,7 +22,6 @@ object WalletSnapshotFixture {
fun new( fun new(
status: Synchronizer.Status = STATUS, status: Synchronizer.Status = STATUS,
processorInfo: CompactBlockProcessor.ProcessorInfo = CompactBlockProcessor.ProcessorInfo( processorInfo: CompactBlockProcessor.ProcessorInfo = CompactBlockProcessor.ProcessorInfo(
null,
null, null,
null, null,
null null

View File

@ -239,9 +239,15 @@ fun HistoryItem(
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny)) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny))
val dateString = transaction.minedHeight?.let {
transaction.blockTimeEpochSeconds?.let { blockTimeEpochSeconds ->
// * 1000 to covert to millis // * 1000 to covert to millis
@Suppress("MagicNumber") @Suppress("MagicNumber")
val dateString = dateFormat.format(transaction.blockTimeEpochSeconds.times(1000)) dateFormat.format(blockTimeEpochSeconds.times(1000L))
} ?: stringResource(id = R.string.history_item_date_not_available)
} ?: stringResource(id = R.string.history_item_date_not_available)
// For now, use the same label for the above missing transaction date
Body( Body(
text = dateString, text = dateString,
maxLines = 1, maxLines = 1,

View File

@ -1,7 +1,7 @@
package co.electriccoin.zcash.ui.screen.home.model package co.electriccoin.zcash.ui.screen.home.model
import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.block.CompactBlockProcessor import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor
import cash.z.ecc.android.sdk.ext.ZcashSdk import cash.z.ecc.android.sdk.ext.ZcashSdk
import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.PercentDecimal
import cash.z.ecc.android.sdk.model.WalletBalance import cash.z.ecc.android.sdk.model.WalletBalance

View File

@ -7,7 +7,8 @@ import cash.z.ecc.android.bip39.Mnemonics
import cash.z.ecc.android.bip39.toSeed import cash.z.ecc.android.bip39.toSeed
import cash.z.ecc.android.sdk.Synchronizer import cash.z.ecc.android.sdk.Synchronizer
import cash.z.ecc.android.sdk.WalletCoordinator import cash.z.ecc.android.sdk.WalletCoordinator
import cash.z.ecc.android.sdk.block.CompactBlockProcessor import cash.z.ecc.android.sdk.WalletInitMode
import cash.z.ecc.android.sdk.block.processor.CompactBlockProcessor
import cash.z.ecc.android.sdk.model.Account import cash.z.ecc.android.sdk.model.Account
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.FiatCurrency import cash.z.ecc.android.sdk.model.FiatCurrency
@ -188,8 +189,12 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
val application = getApplication<Application>() val application = getApplication<Application>()
viewModelScope.launch { viewModelScope.launch {
val newWallet = PersistableWallet.new(application, ZcashNetwork.fromResources(application)) val newWallet = PersistableWallet.new(
persistExistingWallet(newWallet) application,
ZcashNetwork.fromResources(application),
WalletInitMode.NewWallet
)
persistWallet(newWallet)
} }
} }
@ -198,6 +203,13 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
* to see the side effects. This would be used for a user restoring a wallet from a backup. * to see the side effects. This would be used for a user restoring a wallet from a backup.
*/ */
fun persistExistingWallet(persistableWallet: PersistableWallet) { fun persistExistingWallet(persistableWallet: PersistableWallet) {
persistWallet(persistableWallet)
}
/**
* Persists a wallet asynchronously. Clients observe [secretState] to see the side effects.
*/
private fun persistWallet(persistableWallet: PersistableWallet) {
val application = getApplication<Application>() val application = getApplication<Application>()
viewModelScope.launch { viewModelScope.launch {

View File

@ -8,6 +8,7 @@ import androidx.activity.viewModels
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.lifecycle.compose.collectAsStateWithLifecycle import androidx.lifecycle.compose.collectAsStateWithLifecycle
import cash.z.ecc.android.sdk.WalletInitMode
import cash.z.ecc.android.sdk.fixture.WalletFixture import cash.z.ecc.android.sdk.fixture.WalletFixture
import cash.z.ecc.android.sdk.model.BlockHeight import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.PersistableWallet import cash.z.ecc.android.sdk.model.PersistableWallet
@ -133,7 +134,8 @@ internal fun persistExistingWalletWithSeedPhrase(
val restoredWallet = PersistableWallet( val restoredWallet = PersistableWallet(
network, network,
birthday, birthday,
seedPhrase seedPhrase,
WalletInitMode.RestoreWallet
) )
walletViewModel.persistExistingWallet(restoredWallet) walletViewModel.persistExistingWallet(restoredWallet)
} }

View File

@ -9,5 +9,6 @@
<string name="history_item_sending">Sending</string> <string name="history_item_sending">Sending</string>
<string name="history_item_receiving">Receiving</string> <string name="history_item_receiving">Receiving</string>
<string name="history_item_expired">Expired</string> <string name="history_item_expired">Expired</string>
<string name="history_item_date_not_available">Date not available</string>
</resources> </resources>