Skip to content

Commit

Permalink
[#1416] Add shielded transaction type recognition support
Browse files Browse the repository at this point in the history
* [#1416] Shielded transaction UI
---------
Co-authored-by: Honza <[email protected]>
  • Loading branch information
Milan-Cerovsky authored Sep 12, 2024
1 parent aeacc0e commit 57c0766
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- `TransactionOverview.isShielding` has been added to indicate the shielding transaction type

### Changed
- NDK version has been updated to `27.0.12077973`
- Android `compileSdkVersion` and `targetSdkVersion` has been updated to 35
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
const 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 @@ -111,6 +112,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 @@ -139,7 +141,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 @@ -222,4 +225,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,7 +26,8 @@ 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"

Expand All @@ -41,24 +42,26 @@ data class TransactionOverview internal constructor(
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(
latestBlockHeight,
dbTransactionOverview.minedHeight,
dbTransactionOverview.expiryHeight
)
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 57c0766

Please sign in to comment.