2023-03-08 07:04:04 -08:00
|
|
|
package cash.z.ecc.fixture
|
|
|
|
|
2023-05-18 04:36:15 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.Backend
|
2023-03-08 07:04:04 -08:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniBlockMeta
|
2023-07-13 04:18:15 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniScanRange
|
2023-07-18 14:39:26 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniSubtreeRoot
|
2023-05-18 04:36:15 -07:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniUnifiedSpendingKey
|
2023-11-08 01:57:23 -08:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.JniWalletSummary
|
2024-01-08 15:02:52 -08:00
|
|
|
import cash.z.ecc.android.sdk.internal.model.ProposalUnsafe
|
2023-03-08 07:04:04 -08:00
|
|
|
|
|
|
|
internal class FakeRustBackend(
|
2023-05-18 04:36:15 -07:00
|
|
|
override val networkId: Int,
|
2023-03-08 07:04:04 -08:00
|
|
|
val metadata: MutableList<JniBlockMeta>
|
2023-04-10 07:35:40 -07:00
|
|
|
) : Backend {
|
2023-06-09 01:29:33 -07:00
|
|
|
override suspend fun writeBlockMetadata(blockMetadata: List<JniBlockMeta>) {
|
2023-03-08 07:04:04 -08:00
|
|
|
metadata.addAll(blockMetadata)
|
2023-06-09 01:29:33 -07:00
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2023-06-09 01:29:33 -07:00
|
|
|
override suspend fun rewindToHeight(height: Long) {
|
2023-04-10 07:35:40 -07:00
|
|
|
metadata.removeAll { it.height > height }
|
2023-03-08 07:04:04 -08:00
|
|
|
}
|
|
|
|
|
2023-07-18 14:39:26 -07:00
|
|
|
override suspend fun putSaplingSubtreeRoots(
|
|
|
|
startIndex: Long,
|
|
|
|
roots: List<JniSubtreeRoot>,
|
|
|
|
) {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun updateChainTip(height: Long) {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-09-06 12:28:45 -07:00
|
|
|
override suspend fun getFullyScannedHeight(): Long? {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun getMaxScannedHeight(): Long? {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-11-08 01:57:23 -08:00
|
|
|
override suspend fun getWalletSummary(): JniWalletSummary {
|
2023-09-05 18:54:59 -07:00
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-07-13 04:18:15 -07:00
|
|
|
override suspend fun suggestScanRanges(): List<JniScanRange> {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-09-06 12:28:45 -07:00
|
|
|
override suspend fun getLatestCacheHeight(): Long = metadata.maxOf { it.height }
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override suspend fun getTotalTransparentBalance(address: String): Long {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-05-18 04:36:15 -07:00
|
|
|
override suspend fun putUtxo(
|
|
|
|
tAddress: String,
|
|
|
|
txId: ByteArray,
|
|
|
|
index: Int,
|
|
|
|
script: ByteArray,
|
|
|
|
value: Long,
|
|
|
|
height: Long
|
2023-06-09 01:29:33 -07:00
|
|
|
) {
|
2023-05-18 04:36:15 -07:00
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override suspend fun findBlockMetadata(height: Long): JniBlockMeta? {
|
|
|
|
return metadata.findLast { it.height == height }
|
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun rewindBlockMetadataToHeight(height: Long) {
|
|
|
|
metadata.removeAll { it.height > height }
|
2023-03-08 07:04:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
override suspend fun initBlockMetaDb(): Int =
|
2024-01-04 12:21:32 -08:00
|
|
|
error(
|
|
|
|
"Intentionally not implemented in mocked FakeRustBackend implementation."
|
|
|
|
)
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2024-01-08 15:02:52 -08:00
|
|
|
override suspend fun proposeTransfer(
|
2023-04-10 07:35:40 -07:00
|
|
|
account: Int,
|
|
|
|
to: String,
|
|
|
|
value: Long,
|
|
|
|
memo: ByteArray?
|
2024-01-08 15:02:52 -08:00
|
|
|
): ProposalUnsafe {
|
2023-04-10 07:35:40 -07:00
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2024-01-08 15:02:52 -08:00
|
|
|
override suspend fun proposeShielding(
|
2024-01-04 12:21:32 -08:00
|
|
|
account: Int,
|
2024-02-27 11:00:06 -08:00
|
|
|
shieldingThreshold: Long,
|
2024-02-27 17:44:12 -08:00
|
|
|
memo: ByteArray?,
|
|
|
|
transparentReceiver: String?
|
|
|
|
): ProposalUnsafe? {
|
2024-01-08 15:02:52 -08:00
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
|
|
|
|
2024-03-01 10:51:54 -08:00
|
|
|
override suspend fun createProposedTransactions(
|
2024-01-08 15:02:52 -08:00
|
|
|
proposal: ProposalUnsafe,
|
|
|
|
unifiedSpendingKey: ByteArray
|
2024-03-01 10:51:54 -08:00
|
|
|
): List<ByteArray> {
|
2023-04-10 07:35:40 -07:00
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
|
|
|
override suspend fun decryptAndStoreTransaction(tx: ByteArray) =
|
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
|
|
|
override suspend fun initDataDb(seed: ByteArray?): Int =
|
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
2023-09-05 18:54:59 -07:00
|
|
|
override suspend fun createAccount(
|
|
|
|
seed: ByteArray,
|
|
|
|
treeState: ByteArray,
|
|
|
|
recoverUntil: Long?
|
2024-01-04 12:21:32 -08:00
|
|
|
): JniUnifiedSpendingKey = error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2024-01-08 09:17:35 -08:00
|
|
|
override fun isValidSaplingAddr(addr: String): Boolean =
|
2023-03-08 07:04:04 -08:00
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
|
|
|
override fun isValidTransparentAddr(addr: String): Boolean =
|
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
|
|
|
override fun isValidUnifiedAddr(addr: String): Boolean =
|
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override suspend fun getCurrentAddress(account: Int): String {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
|
|
|
override fun getTransparentReceiver(ua: String): String? =
|
|
|
|
error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
|
|
|
|
|
|
|
override fun getSaplingReceiver(ua: String): String? =
|
2024-01-04 12:21:32 -08:00
|
|
|
error(
|
|
|
|
"Intentionally not implemented in mocked FakeRustBackend implementation."
|
|
|
|
)
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override suspend fun listTransparentReceivers(account: Int): List<String> {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-09 14:07:59 -08:00
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override fun getBranchIdForHeight(height: Long): Long {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2024-01-04 12:21:32 -08:00
|
|
|
override suspend fun getMemoAsUtf8(
|
|
|
|
txId: ByteArray,
|
|
|
|
outputIndex: Int
|
|
|
|
): String? = error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2023-04-10 07:35:40 -07:00
|
|
|
override suspend fun getNearestRewindHeight(height: Long): Long {
|
|
|
|
TODO("Not yet implemented")
|
|
|
|
}
|
2023-03-08 07:04:04 -08:00
|
|
|
|
2024-01-04 12:21:32 -08:00
|
|
|
override suspend fun scanBlocks(
|
|
|
|
fromHeight: Long,
|
|
|
|
limit: Long
|
|
|
|
) = error("Intentionally not implemented in mocked FakeRustBackend implementation.")
|
2023-03-08 07:04:04 -08:00
|
|
|
}
|