[#939] Eliminate default arguments for Account
* [#939] Eliminate default arguments for Account * Add Account.DEFAULT to demo-app tests * Update changelog
This commit is contained in:
parent
20638afa52
commit
4926e3a24d
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## Unreleased
|
||||
- Synchronizer's functions `getUnifiedAddress`, `getSaplingAddress`, `getTransparentAddress`, and `refreshUtxos` now
|
||||
do not provide `Account.DEFAULT` value for the account argument. As accounts are not fully supported by the SDK
|
||||
yet, the caller should explicitly set Account.DEFAULT as the account argument to keep the same behavior.
|
||||
|
||||
## 1.17.0-beta01
|
||||
- Transparent fund balances are now displayed almost immediately
|
||||
- Synchronization of shielded balances and transaction history is about 30% faster
|
||||
|
|
|
@ -71,7 +71,7 @@ class SampleCodeTest {
|
|||
// Get Address
|
||||
@Test
|
||||
fun getAddress() = runBlocking {
|
||||
val address = synchronizer.getUnifiedAddress()
|
||||
val address = synchronizer.getUnifiedAddress(Account.DEFAULT)
|
||||
assertFalse(address.isBlank())
|
||||
log("Address: $address")
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import cash.z.ecc.android.sdk.demoapp.databinding.FragmentGetAddressBinding
|
|||
import cash.z.ecc.android.sdk.demoapp.ext.requireApplicationContext
|
||||
import cash.z.ecc.android.sdk.demoapp.util.ProvideAddressBenchmarkTrace
|
||||
import cash.z.ecc.android.sdk.demoapp.util.fromResources
|
||||
import cash.z.ecc.android.sdk.model.Account
|
||||
import cash.z.ecc.android.sdk.model.UnifiedFullViewingKey
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.android.sdk.tool.DerivationTool
|
||||
|
@ -32,21 +33,21 @@ class GetAddressFragment : BaseDemoFragment<FragmentGetAddressBinding>() {
|
|||
sharedViewModel.synchronizerFlow.filterNotNull().collect { synchronizer ->
|
||||
binding.unifiedAddress.apply {
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.UNIFIED_ADDRESS_START)
|
||||
val uaddress = synchronizer.getUnifiedAddress()
|
||||
val uaddress = synchronizer.getUnifiedAddress(Account.DEFAULT)
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.UNIFIED_ADDRESS_END)
|
||||
text = uaddress
|
||||
setOnClickListener { copyToClipboard(uaddress) }
|
||||
}
|
||||
binding.saplingAddress.apply {
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.SAPLING_ADDRESS_START)
|
||||
val sapling = synchronizer.getSaplingAddress()
|
||||
val sapling = synchronizer.getSaplingAddress(Account.DEFAULT)
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.SAPLING_ADDRESS_END)
|
||||
text = sapling
|
||||
setOnClickListener { copyToClipboard(sapling) }
|
||||
}
|
||||
binding.transparentAddress.apply {
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.TRANSPARENT_ADDRESS_START)
|
||||
val transparent = synchronizer.getTransparentAddress()
|
||||
val transparent = synchronizer.getTransparentAddress(Account.DEFAULT)
|
||||
reportTraceEvent(ProvideAddressBenchmarkTrace.Event.TRANSPARENT_ADDRESS_END)
|
||||
text = transparent
|
||||
setOnClickListener { copyToClipboard(transparent) }
|
||||
|
|
|
@ -23,7 +23,7 @@ ZCASH_ASCII_GPG_KEY=
|
|||
# Configures whether release is an unstable snapshot, therefore published to the snapshot repository.
|
||||
IS_SNAPSHOT=true
|
||||
|
||||
LIBRARY_VERSION=1.17.0-beta01
|
||||
LIBRARY_VERSION=1.18.0-beta01
|
||||
|
||||
# Kotlin compiler warnings can be considered errors, failing the build.
|
||||
ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=true
|
||||
|
|
|
@ -67,7 +67,7 @@ class TestnetIntegrationTest : ScopedTest() {
|
|||
@Test
|
||||
@Ignore("This test is broken")
|
||||
fun getAddress() = runBlocking {
|
||||
assertEquals(address, synchronizer.getUnifiedAddress())
|
||||
assertEquals(address, synchronizer.getUnifiedAddress(Account.DEFAULT))
|
||||
}
|
||||
|
||||
// This is an extremely slow test; it is disabled so that we can get CI set up
|
||||
|
|
|
@ -372,7 +372,7 @@ class SdkSynchronizer private constructor(
|
|||
|
||||
suspend fun refreshTransparentBalance() {
|
||||
Twig.debug { "refreshing transparent balance" }
|
||||
_transparentBalances.value = processor.getUtxoCacheBalance(getTransparentAddress())
|
||||
_transparentBalances.value = processor.getUtxoCacheBalance(getTransparentAddress(Account.DEFAULT))
|
||||
}
|
||||
|
||||
suspend fun isValidAddress(address: String): Boolean {
|
||||
|
@ -385,7 +385,7 @@ class SdkSynchronizer private constructor(
|
|||
// Triggering UTXOs fetch and transparent balance update at the beginning of the block sync right after the app
|
||||
// start, as it makes the transparent transactions appearance faster
|
||||
launch(CoroutineExceptionHandler(::onCriticalError)) {
|
||||
refreshUtxos()
|
||||
refreshUtxos(Account.DEFAULT)
|
||||
refreshTransparentBalance()
|
||||
refreshTransactions()
|
||||
}
|
||||
|
@ -487,7 +487,7 @@ class SdkSynchronizer private constructor(
|
|||
|
||||
if (shouldRefresh) {
|
||||
Twig.debug { "Triggering utxo refresh since $reason!" }
|
||||
refreshUtxos()
|
||||
refreshUtxos(Account.DEFAULT)
|
||||
|
||||
Twig.debug { "Triggering balance refresh since $reason!" }
|
||||
refreshAllBalances()
|
||||
|
|
|
@ -132,32 +132,32 @@ interface Synchronizer {
|
|||
/**
|
||||
* Gets the current unified address for the given account.
|
||||
*
|
||||
* @param accountId the optional accountId whose address is of interest. By default, the first
|
||||
* account is used.
|
||||
* @param account the account whose address is of interest. Use Account.DEFAULT to get a result for the first
|
||||
* account.
|
||||
*
|
||||
* @return the current unified address for the given account.
|
||||
*/
|
||||
suspend fun getUnifiedAddress(account: Account = Account.DEFAULT): String
|
||||
suspend fun getUnifiedAddress(account: Account): String
|
||||
|
||||
/**
|
||||
* Gets the legacy Sapling address corresponding to the current unified address for the given account.
|
||||
*
|
||||
* @param account the optional accountId whose address is of interest. By default, the first
|
||||
* account is used.
|
||||
* @param account the account whose address is of interest. Use Account.DEFAULT to get a result for the first
|
||||
* account.
|
||||
*
|
||||
* @return a legacy Sapling address for the given account.
|
||||
*/
|
||||
suspend fun getSaplingAddress(account: Account = Account.DEFAULT): String
|
||||
suspend fun getSaplingAddress(account: Account): String
|
||||
|
||||
/**
|
||||
* Gets the legacy transparent address corresponding to the current unified address for the given account.
|
||||
*
|
||||
* @param account the optional accountId whose address is of interest. By default, the first
|
||||
* account is used.
|
||||
* @param account the account whose address is of interest. Use Account.DEFAULT to get a result for the first
|
||||
* account.
|
||||
*
|
||||
* @return a legacy transparent address for the given account.
|
||||
*/
|
||||
suspend fun getTransparentAddress(account: Account = Account.DEFAULT): String
|
||||
suspend fun getTransparentAddress(account: Account): String
|
||||
|
||||
/**
|
||||
* Sends zatoshi.
|
||||
|
@ -252,13 +252,14 @@ interface Synchronizer {
|
|||
/**
|
||||
* Download all UTXOs for the given account addresses and store any new ones in the database.
|
||||
*
|
||||
* @param account The Account, for which all addresses blocks will be downloaded.
|
||||
* @param account The Account, for which all addresses blocks will be downloaded. Use Account.DEFAULT to get a
|
||||
* result for the first account.
|
||||
* @param since The BlockHeight, from which blocks will be downloaded.
|
||||
*
|
||||
* @return the number of utxos that were downloaded and added to the UTXO table.
|
||||
*/
|
||||
suspend fun refreshUtxos(
|
||||
account: Account = Account.DEFAULT,
|
||||
account: Account,
|
||||
since: BlockHeight = network.saplingActivationHeight
|
||||
): Int?
|
||||
|
||||
|
|
Loading…
Reference in New Issue