[#972] Adopt PersistableWallet API changes in SDK

* [#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

* Switch to latest v2.0.0-rc.2

* Adopt latest SDK snapshot version

* [#972] Adopt PersistableWallet API changes in SDK

Closes  #972.

* Adopt SDK supporting PersistableWallet.endpoint
This commit is contained in:
Honza Rychnovský 2023-09-28 12:05:36 +02:00 committed by GitHub
parent 9ec0de1729
commit 3b1d42528d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 9 deletions

View File

@ -153,9 +153,10 @@ PLAY_APP_UPDATE_VERSION=2.0.1
PLAY_APP_UPDATE_KTX_VERSION=2.0.1
ZCASH_ANDROID_WALLET_PLUGINS_VERSION=1.0.0
ZCASH_BIP39_VERSION=1.0.5
ZCASH_SDK_VERSION=2.0.0
ZXING_VERSION=3.5.1
# Ensure a non-snapshot version is used before releasing to production.
ZCASH_SDK_VERSION=2.0.0-SNAPSHOT
# Toolchain is the Java version used to build the application, which is separate from the
# Java version used to run the application.

View File

@ -2,14 +2,18 @@ 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.Mainnet
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.android.sdk.model.SeedPhrase
import cash.z.ecc.android.sdk.model.ZcashNetwork
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
object PersistableWalletFixture {
val NETWORK = ZcashNetwork.Mainnet
val ENDPOINT = LightWalletEndpoint.Mainnet
@Suppress("MagicNumber")
val BIRTHDAY = BlockHeight.new(ZcashNetwork.Mainnet, 626603L)
@ -19,8 +23,9 @@ object PersistableWalletFixture {
fun new(
network: ZcashNetwork = NETWORK,
endpoint: LightWalletEndpoint = ENDPOINT,
birthday: BlockHeight = BIRTHDAY,
seedPhrase: SeedPhrase = SEED_PHRASE,
walletInitMode: WalletInitMode = WALLET_INIT_MODE
) = PersistableWallet(network, birthday, seedPhrase, walletInitMode)
) = PersistableWallet(network, endpoint, birthday, seedPhrase, walletInitMode)
}

View File

@ -19,8 +19,10 @@ import cash.z.ecc.android.sdk.model.WalletAddresses
import cash.z.ecc.android.sdk.model.WalletBalance
import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.android.sdk.model.defaultForNetwork
import cash.z.ecc.android.sdk.tool.DerivationTool
import cash.z.ecc.sdk.type.fromResources
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import co.electriccoin.zcash.global.getInstance
import co.electriccoin.zcash.spackle.Twig
import co.electriccoin.zcash.ui.common.ANDROID_STATE_FLOW_TIMEOUT
@ -189,10 +191,12 @@ class WalletViewModel(application: Application) : AndroidViewModel(application)
val application = getApplication<Application>()
viewModelScope.launch {
val zcashNetwork = ZcashNetwork.fromResources(application)
val newWallet = PersistableWallet.new(
application,
ZcashNetwork.fromResources(application),
WalletInitMode.NewWallet
application = application,
zcashNetwork = zcashNetwork,
endpoint = LightWalletEndpoint.defaultForNetwork(zcashNetwork),
walletInitMode = WalletInitMode.NewWallet
)
persistWallet(newWallet)
}

View File

@ -14,7 +14,9 @@ import cash.z.ecc.android.sdk.model.BlockHeight
import cash.z.ecc.android.sdk.model.PersistableWallet
import cash.z.ecc.android.sdk.model.SeedPhrase
import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.android.sdk.model.defaultForNetwork
import cash.z.ecc.sdk.type.fromResources
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import co.electriccoin.zcash.spackle.EmulatorWtfUtil
import co.electriccoin.zcash.spackle.FirebaseTestLabUtil
import co.electriccoin.zcash.ui.BuildConfig
@ -132,10 +134,11 @@ internal fun persistExistingWalletWithSeedPhrase(
val network = ZcashNetwork.fromResources(context)
val restoredWallet = PersistableWallet(
network,
birthday,
seedPhrase,
WalletInitMode.RestoreWallet
network = network,
birthday = birthday,
endpoint = LightWalletEndpoint.defaultForNetwork(network),
seedPhrase = seedPhrase,
walletInitMode = WalletInitMode.RestoreWallet
)
walletViewModel.persistExistingWallet(restoredWallet)
}