Skip to content

Commit ddfa640

Browse files
committed
feat: ZSA-aware transaction history (list + detail view)
- Add zsa_value + asset_id columns to transactions table - Compute ZSA summary in summarize_tx (first asset net amount) - Add asset_display helper fn (resolved from name or desc_hash, fallback ZEC) - Tx struct: zsaValue, assetId, assetDisplay fields - TxNote/TxSpend: idAsset + assetDisplay fields (join assets in queries) - TransactionTile shows ZSA value below ZEC amount - Tx detail page shows asset name and raw value for ZSA notes/spends - Fix calculate_balance to only count ZEC notes (id_asset IS NULL) - Fix max_spendable to only count ZEC notes
1 parent a716a0b commit ddfa640

14 files changed

Lines changed: 539 additions & 113 deletions

File tree

lib/pages/account.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,8 @@ List<Widget> showTxHistory(BuildContext context, List<Tx> transactions) {
690690
date: tx.time,
691691
id: tx.id,
692692
onTap: () => gotoTransaction(context, tx.id),
693+
zsaValue: tx.zsaValue != 0 ? BigInt.from(tx.zsaValue) : null,
694+
zsaLabel: tx.zsaValue != 0 ? tx.assetDisplay : null,
693695
);
694696

695697
return Column(children: [

lib/pages/tx_view.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,12 @@ class TxViewPageState extends ConsumerState<TxViewPage> {
135135
...txd.spends.expand(
136136
(n) => [
137137
ListTile(title: Text("Pool"), subtitle: CopyableText(poolToString(n.pool))),
138+
ListTile(title: Text("Asset"), subtitle: CopyableText(n.assetDisplay)),
138139
ListTile(
139140
title: Text("Value"),
140-
subtitle: zatToText(n.value, selectable: true),
141+
subtitle: n.idAsset != null
142+
? Text(n.value.toString())
143+
: zatToText(n.value, selectable: true),
141144
),
142145
Divider(),
143146
],
@@ -146,9 +149,12 @@ class TxViewPageState extends ConsumerState<TxViewPage> {
146149
...txd.notes.expand(
147150
(n) => [
148151
ListTile(title: Text("Pool"), subtitle: CopyableText(poolToString(n.pool))),
152+
ListTile(title: Text("Asset"), subtitle: CopyableText(n.assetDisplay)),
149153
ListTile(
150154
title: Text("Value"),
151-
subtitle: zatToText(n.value, selectable: true),
155+
subtitle: n.idAsset != null
156+
? Text(n.value.toString())
157+
: zatToText(n.value, selectable: true),
152158
),
153159
Divider(),
154160
],

lib/src/rust/api/account.dart

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ sealed class Tx with _$Tx {
387387
required PlatformInt64 value,
388388
int? tpe,
389389
String? category,
390+
required PlatformInt64 zsaValue,
391+
int? assetId,
392+
required String assetDisplay,
390393
}) = _Tx;
391394
}
392395

@@ -494,6 +497,7 @@ class TxNote {
494497
final bool locked;
495498
final String? memo;
496499
final int? idAsset;
500+
final String assetDisplay;
497501

498502
const TxNote({
499503
required this.id,
@@ -506,6 +510,7 @@ class TxNote {
506510
required this.locked,
507511
this.memo,
508512
this.idAsset,
513+
required this.assetDisplay,
509514
});
510515

511516
static Future<TxNote> default_() =>
@@ -522,7 +527,8 @@ class TxNote {
522527
value.hashCode ^
523528
locked.hashCode ^
524529
memo.hashCode ^
525-
idAsset.hashCode;
530+
idAsset.hashCode ^
531+
assetDisplay.hashCode;
526532

527533
@override
528534
bool operator ==(Object other) =>
@@ -538,7 +544,8 @@ class TxNote {
538544
value == other.value &&
539545
locked == other.locked &&
540546
memo == other.memo &&
541-
idAsset == other.idAsset;
547+
idAsset == other.idAsset &&
548+
assetDisplay == other.assetDisplay;
542549
}
543550

544551
class TxOutput {
@@ -584,20 +591,29 @@ class TxSpend {
584591
final int pool;
585592
final int height;
586593
final BigInt value;
594+
final int? idAsset;
595+
final String assetDisplay;
587596

588597
const TxSpend({
589598
required this.id,
590599
required this.pool,
591600
required this.height,
592601
required this.value,
602+
this.idAsset,
603+
required this.assetDisplay,
593604
});
594605

595606
static Future<TxSpend> default_() =>
596607
RustLib.instance.api.crateApiAccountTxSpendDefault();
597608

598609
@override
599610
int get hashCode =>
600-
id.hashCode ^ pool.hashCode ^ height.hashCode ^ value.hashCode;
611+
id.hashCode ^
612+
pool.hashCode ^
613+
height.hashCode ^
614+
value.hashCode ^
615+
idAsset.hashCode ^
616+
assetDisplay.hashCode;
601617

602618
@override
603619
bool operator ==(Object other) =>
@@ -607,5 +623,7 @@ class TxSpend {
607623
id == other.id &&
608624
pool == other.pool &&
609625
height == other.height &&
610-
value == other.value;
626+
value == other.value &&
627+
idAsset == other.idAsset &&
628+
assetDisplay == other.assetDisplay;
611629
}

0 commit comments

Comments
 (0)