[#1153] Adopt SDK v2.0.4

* [#1153] Adopt SDK v2.0.4
- Closes #1153
- Add TODO inline
- Changelog update
This commit is contained in:
Honza Rychnovský 2024-01-09 12:27:32 +01:00 committed by GitHub
parent 803ea86d8d
commit d1eec2dae8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 63 additions and 13 deletions

View File

@ -13,6 +13,9 @@ directly impact users rather than highlighting other key architectural updates.*
- Transaction history items now display Memos within the Android Toast, triggered by clicking the item - Transaction history items now display Memos within the Android Toast, triggered by clicking the item
- Transaction history items add displaying transaction IDs; the ID element is also clickable - Transaction history items add displaying transaction IDs; the ID element is also clickable
### Changed
- All project dependencies have been updated, including the Zcash SDK dependency
## [0.2.0 (517)] - 2023-12-21 ## [0.2.0 (517)] - 2023-12-21
### Changed ### Changed

View File

@ -188,7 +188,7 @@ ZCASH_BIP39_VERSION=1.0.7
ZXING_VERSION=3.5.2 ZXING_VERSION=3.5.2
# WARNING: Ensure a non-snapshot version is used before releasing to production. # WARNING: Ensure a non-snapshot version is used before releasing to production.
ZCASH_SDK_VERSION=2.0.3 ZCASH_SDK_VERSION=2.0.4-SNAPSHOT
# Toolchain is the Java version used to build the application, which is separate from the # Toolchain is the Java version used to build the application, which is separate from the
# Java version used to run the application. # Java version used to run the application.

View File

@ -5,6 +5,7 @@ import cash.z.ecc.android.sdk.model.MonetarySeparators
import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.PercentDecimal
import kotlinx.coroutines.test.runTest import kotlinx.coroutines.test.runTest
import org.junit.Test import org.junit.Test
import java.util.Locale
import kotlin.test.assertEquals import kotlin.test.assertEquals
class PercentDecimalExtTest { class PercentDecimalExtTest {
@ -32,7 +33,7 @@ class PercentDecimalExtTest {
runTest { runTest {
val parsed = PercentDecimal(1f).toPercentageWithDecimal() val parsed = PercentDecimal(1f).toPercentageWithDecimal()
assertEquals("100${MonetarySeparators.current().decimal}00", parsed) assertEquals("100${MonetarySeparators.current(Locale.US).decimal}00", parsed)
} }
@Test @Test

View File

@ -0,0 +1,36 @@
@file:Suppress("ktlint:standard:filename")
package cash.z.ecc.sdk.extension
import cash.z.ecc.android.sdk.model.ZcashNetwork
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
/*
* This set of extension functions suit for default values for the SDK initialization.
*/
fun LightWalletEndpoint.Companion.defaultForNetwork(zcashNetwork: ZcashNetwork): LightWalletEndpoint {
return when (zcashNetwork.id) {
ZcashNetwork.Mainnet.id -> LightWalletEndpoint.Mainnet
ZcashNetwork.Testnet.id -> LightWalletEndpoint.Testnet
else -> error("Unknown network id: ${zcashNetwork.id}")
}
}
private const val DEFAULT_PORT = 9067
val LightWalletEndpoint.Companion.Mainnet
get() =
LightWalletEndpoint(
"mainnet.lightwalletd.com",
DEFAULT_PORT,
isSecure = true
)
val LightWalletEndpoint.Companion.Testnet
get() =
LightWalletEndpoint(
"lightwalletd.testnet.electriccoin.co",
DEFAULT_PORT,
isSecure = true
)

View File

@ -7,6 +7,7 @@ import cash.z.ecc.android.sdk.model.MonetarySeparators
import cash.z.ecc.android.sdk.model.PercentDecimal import cash.z.ecc.android.sdk.model.PercentDecimal
import java.math.RoundingMode import java.math.RoundingMode
import java.text.DecimalFormat import java.text.DecimalFormat
import java.util.Locale
@Suppress("MagicNumber") @Suppress("MagicNumber")
fun PercentDecimal.toPercentageWithDecimal(decimalFormat: DecimalFormat = preparePercentDecimalFormat()): String { fun PercentDecimal.toPercentageWithDecimal(decimalFormat: DecimalFormat = preparePercentDecimalFormat()): String {
@ -15,7 +16,9 @@ fun PercentDecimal.toPercentageWithDecimal(decimalFormat: DecimalFormat = prepar
private fun preparePercentDecimalFormat(): DecimalFormat = private fun preparePercentDecimalFormat(): DecimalFormat =
DecimalFormat().apply { DecimalFormat().apply {
val monetarySeparators = MonetarySeparators.current() // TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
val monetarySeparators = MonetarySeparators.current(Locale.US)
val localizedPattern = "##0${monetarySeparators.decimal}00" val localizedPattern = "##0${monetarySeparators.decimal}00"
runCatching { runCatching {
applyLocalizedPattern(localizedPattern) applyLocalizedPattern(localizedPattern)

View File

@ -2,10 +2,10 @@ package cash.z.ecc.sdk.fixture
import cash.z.ecc.android.sdk.WalletInitMode 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.Mainnet
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
import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.sdk.extension.Mainnet
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
object PersistableWalletFixture { object PersistableWalletFixture {

View File

@ -19,8 +19,8 @@ import cash.z.ecc.android.sdk.model.WalletAddresses
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
import cash.z.ecc.android.sdk.model.ZcashNetwork 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.android.sdk.tool.DerivationTool
import cash.z.ecc.sdk.extension.defaultForNetwork
import cash.z.ecc.sdk.type.fromResources import cash.z.ecc.sdk.type.fromResources
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import co.electriccoin.zcash.global.getInstance import co.electriccoin.zcash.global.getInstance

View File

@ -39,7 +39,9 @@ data class WalletDisplayValues(
walletSnapshot.spendableBalance().toFiatCurrencyState( walletSnapshot.spendableBalance().toFiatCurrencyState(
null, null,
Locale.current.toKotlinLocale(), Locale.current.toKotlinLocale(),
MonetarySeparators.current() // TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
MonetarySeparators.current(java.util.Locale.US)
) )
var fiatCurrencyAmountText = getFiatCurrencyRateValue(context, fiatCurrencyAmountState) var fiatCurrencyAmountText = getFiatCurrencyRateValue(context, fiatCurrencyAmountState)

View File

@ -346,10 +346,7 @@ fun HistoryItem(
} }
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny)) Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingTiny))
// TODO [#1316]: Provide readable TxId on TransactionOverview val txId = transaction.txIdString()
// TODO [#1316]: https://github.com/Electric-Coin-Company/zcash-android-wallet-sdk/issues/1316
// TODO [#1316]: transaction.rawId.byteArray.toHexReversed()
val txId = "TODO [#1316]: SDK: Provide readable TxId"
Tiny( Tiny(
text = txId, text = txId,
modifier = modifier =

View File

@ -13,7 +13,7 @@ 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
import cash.z.ecc.android.sdk.model.ZcashNetwork import cash.z.ecc.android.sdk.model.ZcashNetwork
import cash.z.ecc.android.sdk.model.defaultForNetwork import cash.z.ecc.sdk.extension.defaultForNetwork
import cash.z.ecc.sdk.type.fromResources import cash.z.ecc.sdk.type.fromResources
import co.electriccoin.lightwallet.client.model.LightWalletEndpoint import co.electriccoin.lightwallet.client.model.LightWalletEndpoint
import co.electriccoin.zcash.spackle.FirebaseTestLabUtil import co.electriccoin.zcash.spackle.FirebaseTestLabUtil

View File

@ -43,6 +43,7 @@ import co.electriccoin.zcash.ui.design.component.GradientSurface
import co.electriccoin.zcash.ui.design.component.PrimaryButton import co.electriccoin.zcash.ui.design.component.PrimaryButton
import co.electriccoin.zcash.ui.design.theme.ZcashTheme import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import java.util.Locale
@Preview("Request") @Preview("Request")
@Composable @Composable
@ -112,7 +113,9 @@ private fun RequestMainContent(
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
val context = LocalContext.current val context = LocalContext.current
val monetarySeparators = MonetarySeparators.current() // TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
val monetarySeparators = MonetarySeparators.current(Locale.US)
val allowedCharacters = ZecString.allowedCharacters(monetarySeparators) val allowedCharacters = ZecString.allowedCharacters(monetarySeparators)
var amountZecString by rememberSaveable { mutableStateOf("") } var amountZecString by rememberSaveable { mutableStateOf("") }

View File

@ -72,6 +72,7 @@ import co.electriccoin.zcash.ui.screen.send.ext.valueOrEmptyChar
import co.electriccoin.zcash.ui.screen.send.model.SendArgumentsWrapper import co.electriccoin.zcash.ui.screen.send.model.SendArgumentsWrapper
import co.electriccoin.zcash.ui.screen.send.model.SendStage import co.electriccoin.zcash.ui.screen.send.model.SendStage
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import java.util.Locale
@Composable @Composable
@Preview("SendForm") @Preview("SendForm")
@ -304,7 +305,9 @@ private fun SendForm(
modifier: Modifier = Modifier modifier: Modifier = Modifier
) { ) {
val context = LocalContext.current val context = LocalContext.current
val monetarySeparators = MonetarySeparators.current() // TODO [#1171]: Remove default MonetarySeparators locale
// TODO [#1171]: https://github.com/Electric-Coin-Company/zashi-android/issues/1171
val monetarySeparators = MonetarySeparators.current(Locale.US)
val allowedCharacters = ZecString.allowedCharacters(monetarySeparators) val allowedCharacters = ZecString.allowedCharacters(monetarySeparators)
val focusManager = LocalFocusManager.current val focusManager = LocalFocusManager.current

View File

@ -24,6 +24,8 @@ data class EnvironmentInfo(
return EnvironmentInfo( return EnvironmentInfo(
context.resources.configuration.locales[0], context.resources.configuration.locales[0],
// This MonetarySeparators calling reflects the real separators according to device Locale as its
// goal is to represent information about the device, and it's not considered to be used in UI
MonetarySeparators.current(), MonetarySeparators.current(),
usableStorage usableStorage
) )