Skip to content

Commit

Permalink
[#1416] Shielded transaction UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan-Cerovsky committed Aug 19, 2024
1 parent 1d5a2ef commit a078f28
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ object TransactionOverviewFixture {
const val MEMO_COUNT: Int = 0
const val BLOCK_TIME_EPOCH_SECONDS: Long = 1234
val STATE = TransactionState.Confirmed
val IS_SHIELDING = false

@Suppress("LongParameterList")
fun new(
Expand All @@ -40,21 +41,23 @@ object TransactionOverviewFixture {
sentNoteCount: Int = SENT_NOTE_COUNT,
memoCount: Int = MEMO_COUNT,
blockTimeEpochSeconds: Long = BLOCK_TIME_EPOCH_SECONDS,
transactionState: TransactionState = STATE
transactionState: TransactionState = STATE,
isShielding: Boolean = IS_SHIELDING
) = TransactionOverview(
rawId,
minedHeight,
expiryHeight,
index,
raw,
isSentTransaction,
netValue,
feePaid,
isChange,
receivedNoteCount,
sentNoteCount,
memoCount,
blockTimeEpochSeconds,
transactionState
rawId = rawId,
minedHeight = minedHeight,
expiryHeight = expiryHeight,
index = index,
raw = raw,
isSentTransaction = isSentTransaction,
netValue = netValue,
feePaid = feePaid,
isChange = isChange,
receivedNoteCount = receivedNoteCount,
sentNoteCount = sentNoteCount,
memoCount = memoCount,
blockTimeEpochSeconds = blockTimeEpochSeconds,
transactionState = transactionState,
isShielding = isShielding
)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cash.z.ecc.android.sdk.internal.db.derived

import androidx.core.database.getBlobOrNull
import androidx.core.database.getIntOrNull
import androidx.core.database.getLongOrNull
import androidx.sqlite.db.SupportSQLiteDatabase
import cash.z.ecc.android.sdk.internal.db.CursorParser
Expand Down Expand Up @@ -101,6 +102,7 @@ internal class AllTransactionView(
val sentNoteCountIndex = cursor.getColumnIndex(AllTransactionViewDefinition.COLUMN_INTEGER_SENT_NOTE_COUNT)
val memoCountIndex = cursor.getColumnIndex(AllTransactionViewDefinition.COLUMN_INTEGER_MEMO_COUNT)
val blockTimeIndex = cursor.getColumnIndex(AllTransactionViewDefinition.COLUMN_INTEGER_BLOCK_TIME)
val isShielding = cursor.getColumnIndex(AllTransactionViewDefinition.COLUMN_BOOLEAN_IS_SHIELDING)

val netValueLong = cursor.getLong(netValueIndex)
val isSent = netValueLong < 0
Expand Down Expand Up @@ -129,7 +131,8 @@ internal class AllTransactionView(
receivedNoteCount = cursor.getInt(receivedNoteCountIndex),
sentNoteCount = cursor.getInt(sentNoteCountIndex),
memoCount = cursor.getInt(memoCountIndex),
blockTimeEpochSeconds = cursor.getLongOrNull(blockTimeIndex)
blockTimeEpochSeconds = cursor.getLongOrNull(blockTimeIndex),
isShielding = cursor.getIntOrNull(isShielding) == 1
)
}

Expand Down Expand Up @@ -212,4 +215,6 @@ internal object AllTransactionViewDefinition {
const val COLUMN_INTEGER_MEMO_COUNT = "memo_count" // $NON-NLS

const val COLUMN_INTEGER_BLOCK_TIME = "block_time" // $NON-NLS

const val COLUMN_BOOLEAN_IS_SHIELDING = "is_shielding" // $NON-NLS
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ internal data class DbTransactionOverview internal constructor(
val receivedNoteCount: Int,
val sentNoteCount: Int,
val memoCount: Int,
val blockTimeEpochSeconds: Long?
val blockTimeEpochSeconds: Long?,
val isShielding: Boolean,
) {
override fun toString() = "DbTransactionOverview"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,39 +26,41 @@ data class TransactionOverview internal constructor(
val sentNoteCount: Int,
val memoCount: Int,
val blockTimeEpochSeconds: Long?,
val transactionState: TransactionState
val transactionState: TransactionState,
val isShielding: Boolean
) {
override fun toString() = "TransactionOverview"

/**
* @return Transaction ID in String obtained from `rawId`
*/
fun txIdString() = rawId.byteArray.toHexReversed()
fun txIdString() = rawId.byteArray.toHexReversed().takeIf { it.isNotEmpty() }

companion object {
internal fun new(
dbTransactionOverview: DbTransactionOverview,
latestBlockHeight: BlockHeight?
): TransactionOverview {
return TransactionOverview(
dbTransactionOverview.rawId,
dbTransactionOverview.minedHeight,
dbTransactionOverview.expiryHeight,
dbTransactionOverview.index,
dbTransactionOverview.raw,
dbTransactionOverview.isSentTransaction,
dbTransactionOverview.netValue,
dbTransactionOverview.feePaid,
dbTransactionOverview.isChange,
dbTransactionOverview.receivedNoteCount,
dbTransactionOverview.sentNoteCount,
dbTransactionOverview.memoCount,
dbTransactionOverview.blockTimeEpochSeconds,
TransactionState.new(
rawId = dbTransactionOverview.rawId,
minedHeight = dbTransactionOverview.minedHeight,
expiryHeight = dbTransactionOverview.expiryHeight,
index = dbTransactionOverview.index,
raw = dbTransactionOverview.raw,
isSentTransaction = dbTransactionOverview.isSentTransaction,
netValue = dbTransactionOverview.netValue,
feePaid = dbTransactionOverview.feePaid,
isChange = dbTransactionOverview.isChange,
receivedNoteCount = dbTransactionOverview.receivedNoteCount,
sentNoteCount = dbTransactionOverview.sentNoteCount,
memoCount = dbTransactionOverview.memoCount,
blockTimeEpochSeconds = dbTransactionOverview.blockTimeEpochSeconds,
transactionState = TransactionState.new(
latestBlockHeight,
dbTransactionOverview.minedHeight,
dbTransactionOverview.expiryHeight
)
),
isShielding = dbTransactionOverview.isShielding
)
}
}
Expand Down

0 comments on commit a078f28

Please sign in to comment.