From 3b1d42528d25c1f5b49add7f29e8ce77ceaf3f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Rychnovsk=C3=BD?= Date: Thu, 28 Sep 2023 12:05:36 +0200 Subject: [PATCH] [#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 --- gradle.properties | 3 ++- .../z/ecc/sdk/fixture/PersistableWalletFixture.kt | 7 ++++++- .../zcash/ui/screen/home/viewmodel/WalletViewModel.kt | 10 +++++++--- .../zcash/ui/screen/onboarding/AndroidOnboarding.kt | 11 +++++++---- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/gradle.properties b/gradle.properties index 07909bab8..5aede9a7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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. diff --git a/sdk-ext-lib/src/main/java/cash/z/ecc/sdk/fixture/PersistableWalletFixture.kt b/sdk-ext-lib/src/main/java/cash/z/ecc/sdk/fixture/PersistableWalletFixture.kt index 453917d3a..1aeccc7d1 100644 --- a/sdk-ext-lib/src/main/java/cash/z/ecc/sdk/fixture/PersistableWalletFixture.kt +++ b/sdk-ext-lib/src/main/java/cash/z/ecc/sdk/fixture/PersistableWalletFixture.kt @@ -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) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/viewmodel/WalletViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/viewmodel/WalletViewModel.kt index e0b82c9b3..7f4d94273 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/viewmodel/WalletViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/home/viewmodel/WalletViewModel.kt @@ -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() 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) } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/onboarding/AndroidOnboarding.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/onboarding/AndroidOnboarding.kt index f936d9f61..65c7026cf 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/onboarding/AndroidOnboarding.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/screen/onboarding/AndroidOnboarding.kt @@ -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) }