[#1030] Make sdk-lib gRPC objects free
- This follows our goal of having the sdk-lib module completely separated from the networking layer
This commit is contained in:
parent
68e7e1f7de
commit
20638afa52
|
@ -111,14 +111,11 @@ protobuf {
|
|||
|
||||
dependencies {
|
||||
implementation(libs.androidx.annotation)
|
||||
implementation(libs.bundles.grpc)
|
||||
implementation(libs.kotlin.stdlib)
|
||||
implementation(libs.kotlinx.coroutines.core)
|
||||
implementation(libs.kotlinx.coroutines.android)
|
||||
|
||||
// TODO [#1030]: Make sdk-lib gRPC objects free (and then make this `implementation`)
|
||||
// TODO [#1030]: https://github.com/zcash/zcash-android-wallet-sdk/issues/1030
|
||||
api(libs.bundles.grpc)
|
||||
|
||||
// Tests
|
||||
testImplementation(libs.kotlin.reflect)
|
||||
testImplementation(libs.kotlin.test)
|
||||
|
|
|
@ -4,10 +4,7 @@ import cash.z.ecc.android.sdk.internal.SaplingParameters
|
|||
import cash.z.ecc.android.sdk.internal.model.Checkpoint
|
||||
import cash.z.ecc.android.sdk.model.BlockHeight
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.wallet.sdk.internal.rpc.Service
|
||||
import co.electriccoin.lightwallet.client.model.BlockHeightUnsafe
|
||||
import io.grpc.Status
|
||||
import io.grpc.Status.Code.UNAVAILABLE
|
||||
|
||||
/**
|
||||
* Marker for all custom exceptions from the SDK. Making it an interface would result in more typing
|
||||
|
@ -238,29 +235,6 @@ sealed class LightWalletException(message: String, cause: Throwable? = null) : S
|
|||
" update the SDK to match lightwalletd or use a lightwalletd that matches the SDK."
|
||||
)
|
||||
|
||||
open class ChangeServerException(message: String, cause: Throwable? = null) : SdkException(message, cause) {
|
||||
class ChainInfoNotMatching(
|
||||
val propertyNames: String,
|
||||
val expectedInfo: Service.LightdInfo,
|
||||
val actualInfo: Service.LightdInfo
|
||||
) : ChangeServerException(
|
||||
"Server change error: the $propertyNames values did not match."
|
||||
)
|
||||
class StatusException(val status: Status, cause: Throwable? = null) : SdkException(status.toMessage(), cause) {
|
||||
companion object {
|
||||
private fun Status.toMessage(): String {
|
||||
return when (this.code) {
|
||||
UNAVAILABLE -> {
|
||||
"Error: the new server is unavailable. Verify that the host and port are correct. Failed " +
|
||||
"with $this"
|
||||
}
|
||||
else -> "Changing servers failed with status $this"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DownloadBlockException(code: Int, description: String?, cause: Throwable) : SdkException(
|
||||
"Failed to download block with code: $code due to: ${description ?: "-"}",
|
||||
cause
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package cash.z.ecc.android.sdk.internal.model
|
||||
|
||||
import cash.z.wallet.sdk.internal.rpc.CompactFormats
|
||||
import co.electriccoin.lightwallet.client.model.CompactBlockUnsafe
|
||||
|
||||
internal fun JniBlockMeta.Companion.new(
|
||||
block: CompactFormats.CompactBlock,
|
||||
outputs: CompactBlockUnsafe.CompactBlockOutputsCounts
|
||||
): JniBlockMeta {
|
||||
return JniBlockMeta(
|
||||
height = block.height,
|
||||
hash = block.hash.toByteArray(),
|
||||
time = block.time.toLong(),
|
||||
saplingOutputsCount = outputs.saplingOutputsCount.toLong(),
|
||||
orchardOutputsCount = outputs.orchardActionsCount.toLong()
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue