Refactor package names

This commit is contained in:
Kevin Gorham 2019-10-24 01:21:52 -04:00
parent f89d2be250
commit bf48b82aa8
No known key found for this signature in database
GPG Key ID: CCA55602DF49FC38
31 changed files with 88 additions and 89 deletions

View File

@ -1,24 +0,0 @@
package cash.z.wallet.sdk.sample.demoapp
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("cash.z.wallet.sdk.sample.demoapp", appContext.packageName)
}
}

View File

@ -1,11 +1,10 @@
package cash.z.wallet.sdk.sample.demoapp
import androidx.test.platform.app.InstrumentationRegistry
import cash.z.wallet.sdk.data.*
import cash.z.wallet.sdk.SdkSynchronizer
import cash.z.wallet.sdk.transaction.*
import cash.z.wallet.sdk.demoapp.util.SampleStorageBridge
import cash.z.wallet.sdk.ext.ZcashSdk
import cash.z.wallet.sdk.ext.convertZecToZatoshi
import cash.z.wallet.sdk.ext.toZec
import cash.z.wallet.sdk.ext.*
import cash.z.wallet.sdk.secure.Wallet
import cash.z.wallet.sdk.service.LightWalletGrpcService
import kotlinx.coroutines.runBlocking

View File

@ -7,8 +7,8 @@ import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope
import androidx.viewbinding.ViewBinding
import cash.z.wallet.sdk.data.TroubleshootingTwig
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.ext.TroubleshootingTwig
import cash.z.wallet.sdk.ext.Twig
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext

View File

@ -13,6 +13,7 @@ import androidx.navigation.ui.setupWithNavController
import androidx.drawerlayout.widget.DrawerLayout
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import cash.z.wallet.sdk.demoapp.util.DemoConfig
class MainActivity : AppCompatActivity() {

View File

@ -8,8 +8,7 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.fragment.NavHostFragment
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.demoapp.App
import cash.z.wallet.sdk.demoapp.R
import cash.z.wallet.sdk.ext.ZcashSdk

View File

@ -1,8 +1,8 @@
package cash.z.wallet.sdk.demoapp.demos.listtransactions
import cash.z.wallet.sdk.data.PagedTransactionRepository
import cash.z.wallet.sdk.data.Synchronizer
import cash.z.wallet.sdk.data.TransactionRepository
import cash.z.wallet.sdk.transaction.PagedTransactionRepository
import cash.z.wallet.sdk.Synchronizer
import cash.z.wallet.sdk.transaction.TransactionRepository
import cash.z.wallet.sdk.demoapp.App
import cash.z.wallet.sdk.demoapp.util.SampleStorageBridge
import cash.z.wallet.sdk.secure.Wallet

View File

@ -5,11 +5,12 @@ import android.view.View
import androidx.lifecycle.lifecycleScope
import androidx.paging.PagedList
import androidx.recyclerview.widget.LinearLayoutManager
import cash.z.wallet.sdk.data.PagedTransactionRepository
import cash.z.wallet.sdk.data.Synchronizer
import cash.z.wallet.sdk.SdkSynchronizer
import cash.z.wallet.sdk.Synchronizer
import cash.z.wallet.sdk.demoapp.BaseDemoFragment
import cash.z.wallet.sdk.demoapp.databinding.FragmentListTransactionsBinding
import cash.z.wallet.sdk.entity.ReceivedTransaction
import cash.z.wallet.sdk.transaction.PagedTransactionRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.flow.collect

View File

@ -4,8 +4,9 @@ import android.view.LayoutInflater
import android.view.View
import android.widget.Toast
import androidx.lifecycle.coroutineScope
import cash.z.wallet.sdk.data.SdkSynchronizer
import cash.z.wallet.sdk.data.Synchronizer
import androidx.lifecycle.lifecycleScope
import cash.z.wallet.sdk.SdkSynchronizer
import cash.z.wallet.sdk.Synchronizer
import cash.z.wallet.sdk.demoapp.App
import cash.z.wallet.sdk.demoapp.BaseDemoFragment
import cash.z.wallet.sdk.demoapp.databinding.FragmentSendBinding

View File

@ -0,0 +1,11 @@
package cash.z.wallet.sdk.demoapp.util
data class DemoConfig(
val host: String = "34.68.177.238",//"192.168.1.134",//
val port: Int = 9067,
val birthdayHeight: Int = 620_000,//523_240,
val network: ZcashNetwork = ZcashNetwork.TEST_NET,
val seed: ByteArray = "testreferencealice".toByteArray()
)
enum class ZcashNetwork { MAIN_NET, TEST_NET }

View File

@ -4,10 +4,9 @@ import androidx.test.platform.app.InstrumentationRegistry
import cash.z.wallet.sdk.block.CompactBlockDbStore
import cash.z.wallet.sdk.block.CompactBlockDownloader
import cash.z.wallet.sdk.block.CompactBlockProcessor
import cash.z.wallet.sdk.data.PollingTransactionRepository
import cash.z.wallet.sdk.data.Synchronizer
import cash.z.wallet.sdk.data.TroubleshootingTwig
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.transaction.PollingTransactionRepository
import cash.z.wallet.sdk.ext.TroubleshootingTwig
import cash.z.wallet.sdk.ext.Twig
import cash.z.wallet.sdk.ext.SampleSeedProvider
import cash.z.wallet.sdk.ext.SampleSpendingKeyProvider
import cash.z.wallet.sdk.jni.RustBackend

View File

@ -1,8 +1,8 @@
package cash.z.wallet.sdk.util
import androidx.test.platform.app.InstrumentationRegistry
import cash.z.wallet.sdk.data.TroubleshootingTwig
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.ext.TroubleshootingTwig
import cash.z.wallet.sdk.ext.Twig
import cash.z.wallet.sdk.ext.SampleSeedProvider
import cash.z.wallet.sdk.jni.RustBackend
import cash.z.wallet.sdk.secure.Wallet

View File

@ -3,9 +3,9 @@ package cash.z.wallet.sdk.db
import androidx.test.platform.app.InstrumentationRegistry
import cash.z.wallet.sdk.block.CompactBlockDbStore
import cash.z.wallet.sdk.block.CompactBlockDownloader
import cash.z.wallet.sdk.data.TroubleshootingTwig
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.ext.TroubleshootingTwig
import cash.z.wallet.sdk.ext.Twig
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.ext.SampleSeedProvider
import cash.z.wallet.sdk.jni.RustBackend
import cash.z.wallet.sdk.secure.Wallet

View File

@ -0,0 +1,6 @@
{
"height": 620000,
"hash": "005f97953c8e1265d6b45f4435ffa32918e53e8f0025c286a4080c3eab167197",
"time": 1569572035,
"tree": "0170cf036ea1ea3c6e08432e18b6a372ca0b8b83671cc13ab0cf9e28c182f6c36f00100000013f3fc2c16ac4780f1c472ca65534ab08911f325a9edde5ea7f24364b47c9a95300017621b12e518cbbbdb7511ab423e0bddda412ed61ed3cff5be2140de65d6a0069010576153a5a2098812e7a028c37c3398e186f398c9b07bc199784ab97e5535c3e0000019a6ce2f0f7dbb2de493a315abf62d8ca96ccc701f116b6ddfae33870a2183d3c01c9d3564eff54ebc328eab2e4f1150c3637f4f47516f879a0cfebdf49fe7b1d5201c104705fac60a85596010e41260d07f3a64f38f37a112eaef41cd9d736edc5270145e3d4899fcd7f0f1236ae31eafb3f4b65ad6b11a17eae1729cec09bd3afa01a000000011f8322ef806eb2430dc4a7a41c1b344bea5be946efc7b4349c1c9edb14ff9d39"
}

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk
import android.content.Context
import cash.z.wallet.sdk.block.CompactBlockDbStore
@ -6,15 +6,17 @@ import cash.z.wallet.sdk.block.CompactBlockDownloader
import cash.z.wallet.sdk.block.CompactBlockProcessor
import cash.z.wallet.sdk.block.CompactBlockProcessor.State.*
import cash.z.wallet.sdk.block.CompactBlockStore
import cash.z.wallet.sdk.data.Synchronizer.Status.*
import cash.z.wallet.sdk.Synchronizer.Status.*
import cash.z.wallet.sdk.entity.ClearedTransaction
import cash.z.wallet.sdk.entity.PendingTransaction
import cash.z.wallet.sdk.entity.SentTransaction
import cash.z.wallet.sdk.exception.SynchronizerException
import cash.z.wallet.sdk.exception.WalletException
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.secure.Wallet
import cash.z.wallet.sdk.service.LightWalletGrpcService
import cash.z.wallet.sdk.service.LightWalletService
import cash.z.wallet.sdk.transaction.*
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.channels.ConflatedBroadcastChannel
@ -65,7 +67,7 @@ fun Synchronizer(
sender: TransactionSender = PersistentTransactionSender(manager, service, ledger),
blockStore: CompactBlockStore = CompactBlockDbStore(appContext),
downloader: CompactBlockDownloader = CompactBlockDownloader(service, blockStore),
processor: CompactBlockProcessor = CompactBlockProcessor(downloader, ledger, wallet.rustBackend),
processor: CompactBlockProcessor = CompactBlockProcessor(downloader, ledger, wallet.rustBackend, wallet.lowerBoundHeight),
encoder: TransactionEncoder = WalletTransactionEncoder(wallet, ledger, keyManager)
): Synchronizer {
// ties everything together
@ -310,14 +312,18 @@ class SdkSynchronizer (
private fun onProcessorError(error: Throwable): Boolean {
twig("ERROR while processing data: $error")
if (onProcessorErrorHandler == null) {
twig("WARNING: falling back to the default behavior for processor errors. To add" +
" custom behavior, set synchronizer.onProcessorErrorHandler to" +
" a non-null value")
twig(
"WARNING: falling back to the default behavior for processor errors. To add" +
" custom behavior, set synchronizer.onProcessorErrorHandler to" +
" a non-null value"
)
return true
}
return onProcessorErrorHandler?.invoke(error)?.also {
twig("processor error handler signaled that we should " +
"${if (it) "try again" else "abort"}!")
twig(
"processor error handler signaled that we should " +
"${if (it) "try again" else "abort"}!"
)
} == true
}

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk
import cash.z.wallet.sdk.entity.ClearedTransaction
import cash.z.wallet.sdk.entity.PendingTransaction

View File

@ -3,9 +3,9 @@ package cash.z.wallet.sdk.block
import androidx.annotation.VisibleForTesting
import cash.z.wallet.sdk.annotation.OpenForTesting
import cash.z.wallet.sdk.block.CompactBlockProcessor.State.*
import cash.z.wallet.sdk.data.TransactionRepository
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.transaction.TransactionRepository
import cash.z.wallet.sdk.ext.Twig
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.exception.CompactBlockProcessorException
import cash.z.wallet.sdk.ext.ZcashSdk.DOWNLOAD_BATCH_SIZE
import cash.z.wallet.sdk.ext.ZcashSdk.MAX_BACKOFF_INTERVAL

View File

@ -4,8 +4,7 @@ import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.ForeignKey
import androidx.room.PrimaryKey
import cash.z.wallet.sdk.data.SignedTransaction
import org.jetbrains.annotations.NotNull
import cash.z.wallet.sdk.transaction.SignedTransaction
//

View File

@ -1,6 +1,5 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.ext
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.CopyOnWriteArraySet
internal typealias Leaf = String
@ -97,7 +96,8 @@ open class TroubleshootingTwig(
* Since there can only ever be one trunk on the bush of twigs, this class lets
* you cheat and make that trunk be a bundle of twigs.
*/
open class CompositeTwig(private val twigBundle: MutableList<Twig>) : Twig {
open class CompositeTwig(private val twigBundle: MutableList<Twig>) :
Twig {
override operator fun plus(twig: Twig): Twig {
if (twig is CompositeTwig) twigBundle.addAll(twig.twigBundle) else twigBundle.add(twig); return this
}

View File

@ -1,7 +1,6 @@
package cash.z.wallet.sdk.ext
import android.content.Context
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.ext.ZcashSdk.MAX_BACKOFF_INTERVAL
import kotlinx.coroutines.delay
import java.io.File

View File

@ -1,7 +1,7 @@
package cash.z.wallet.sdk.jni
import android.content.Context
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.ext.ZcashSdk.OUTPUT_PARAM_FILE_NAME
import cash.z.wallet.sdk.ext.ZcashSdk.SPEND_PARAM_FILE_NAME
import java.io.File

View File

@ -1,9 +1,9 @@
package cash.z.wallet.sdk.secure
import android.content.Context
import cash.z.wallet.sdk.data.Bush
import cash.z.wallet.sdk.data.twig
import cash.z.wallet.sdk.data.twigTask
import cash.z.wallet.sdk.ext.Bush
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.ext.twigTask
import cash.z.wallet.sdk.exception.RustLayerException
import cash.z.wallet.sdk.exception.WalletException
import cash.z.wallet.sdk.exception.WalletException.*
@ -169,10 +169,8 @@ class Wallet {
memo: String = "",
fromAccountIndex: Int = 0
): Long = withContext(IO) {
twigTask(
"creating transaction to spend $value zatoshi to" +
" ${toAddress.masked()} with memo $memo"
) {
twigTask("creating transaction to spend $value zatoshi to" +
" ${toAddress.masked()} with memo $memo") {
try {
ensureParams((rustBackend as RustBackend).paramDestinationDir)
twig("params exist! attempting to send...")

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import android.content.Context
import androidx.lifecycle.LifecycleOwner
@ -13,6 +13,8 @@ import cash.z.wallet.sdk.db.TransactionDao
import cash.z.wallet.sdk.entity.ClearedTransaction
import cash.z.wallet.sdk.entity.Transaction
import cash.z.wallet.sdk.ext.ZcashSdk
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.ext.twigTask
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import android.content.Context
import androidx.room.Room
@ -8,6 +8,7 @@ import cash.z.wallet.sdk.db.PendingTransactionDb
import cash.z.wallet.sdk.entity.PendingTransaction
import cash.z.wallet.sdk.entity.Transaction
import cash.z.wallet.sdk.ext.ZcashSdk.EXPIRY_OFFSET
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.service.LightWalletService
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.withContext

View File

@ -1,12 +1,13 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.data.PersistentTransactionSender.ChangeType.*
import cash.z.wallet.sdk.data.TransactionUpdateRequest.RefreshSentTx
import cash.z.wallet.sdk.data.TransactionUpdateRequest.SubmitPendingTx
import cash.z.wallet.sdk.transaction.PersistentTransactionSender.ChangeType.*
import cash.z.wallet.sdk.transaction.TransactionUpdateRequest.RefreshSentTx
import cash.z.wallet.sdk.transaction.TransactionUpdateRequest.SubmitPendingTx
import cash.z.wallet.sdk.entity.PendingTransaction
import cash.z.wallet.sdk.entity.isMined
import cash.z.wallet.sdk.entity.isPending
import cash.z.wallet.sdk.ext.retryWithBackoff
import cash.z.wallet.sdk.ext.twig
import cash.z.wallet.sdk.service.LightWalletService
import kotlinx.coroutines.*
import kotlinx.coroutines.Dispatchers.IO

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.entity.EncodedTransaction

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.service.LightWalletService

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.entity.Transaction

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.entity.PendingTransaction
import kotlinx.coroutines.CoroutineScope

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.entity.EncodedTransaction
import cash.z.wallet.sdk.exception.TransactionNotEncodedException

View File

@ -1,8 +1,8 @@
package cash.z.wallet.sdk.block
import cash.z.wallet.sdk.data.TransactionRepository
import cash.z.wallet.sdk.data.TroubleshootingTwig
import cash.z.wallet.sdk.data.Twig
import cash.z.wallet.sdk.transaction.TransactionRepository
import cash.z.wallet.sdk.ext.TroubleshootingTwig
import cash.z.wallet.sdk.ext.Twig
import cash.z.wallet.sdk.entity.CompactBlock
import cash.z.wallet.sdk.entity.CompactBlockEntity
import cash.z.wallet.sdk.ext.SAPLING_ACTIVATION_HEIGHT

View File

@ -1,4 +1,4 @@
package cash.z.wallet.sdk.data
package cash.z.wallet.sdk.transaction
import cash.z.wallet.sdk.dao.ClearedTransaction
import kotlinx.coroutines.*