Skip to content

Commit

Permalink
[#972] Adopt PersistableWallet API changes in SDK
Browse files Browse the repository at this point in the history
* [#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
  • Loading branch information
HonzaR authored Sep 28, 2023
1 parent 9ec0de1 commit 3b1d425
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 3b1d425

Please sign in to comment.