Skip to content

Commit e673f61

Browse files
committed
feat: add ordinal spend warning to confirm transaction view
1 parent 54d21e9 commit e673f61

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

lib/pages/send_view/confirm_transaction_view.dart

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ import 'dart:io';
1414

1515
import 'package:decimal/decimal.dart';
1616
import 'package:flutter/material.dart';
17+
import 'package:isar_community/isar.dart';
1718
import 'package:flutter_riverpod/flutter_riverpod.dart';
1819
import 'package:flutter_svg/svg.dart';
1920

21+
import '../../models/input.dart';
2022
import '../../models/isar/models/transaction_note.dart';
23+
import '../../models/isar/ordinal.dart';
2124
import '../../notifications/show_flush_bar.dart';
2225
import '../../pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart';
2326
import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart';
@@ -1418,6 +1421,71 @@ class _ConfirmTransactionViewState
14181421
),
14191422
),
14201423
),
1424+
// Ordinal UTXO spend warning
1425+
Builder(
1426+
builder: (context) {
1427+
final usedUtxos = widget.txData.usedUTXOs;
1428+
if (usedUtxos == null || usedUtxos.isEmpty) {
1429+
return const SizedBox.shrink();
1430+
}
1431+
1432+
final db = ref.read(mainDBProvider);
1433+
bool hasOrdinal = false;
1434+
for (final input in usedUtxos) {
1435+
if (input is StandardInput) {
1436+
final ordinal = db.isar.ordinals
1437+
.where()
1438+
.filter()
1439+
.walletIdEqualTo(walletId)
1440+
.and()
1441+
.utxoTXIDEqualTo(input.utxo.txid)
1442+
.and()
1443+
.utxoVOUTEqualTo(input.utxo.vout)
1444+
.findFirstSync();
1445+
if (ordinal != null) {
1446+
hasOrdinal = true;
1447+
break;
1448+
}
1449+
}
1450+
}
1451+
1452+
if (!hasOrdinal) return const SizedBox.shrink();
1453+
1454+
return Padding(
1455+
padding: isDesktop
1456+
? const EdgeInsets.symmetric(horizontal: 32, vertical: 8)
1457+
: const EdgeInsets.symmetric(vertical: 8),
1458+
child: RoundedContainer(
1459+
color: Theme.of(
1460+
context,
1461+
).extension<StackColors>()!.warningBackground,
1462+
child: Row(
1463+
children: [
1464+
Icon(
1465+
Icons.warning_amber_rounded,
1466+
color: Theme.of(
1467+
context,
1468+
).extension<StackColors>()!.warningForeground,
1469+
size: 20,
1470+
),
1471+
const SizedBox(width: 8),
1472+
Expanded(
1473+
child: Text(
1474+
"This transaction spends a UTXO containing "
1475+
"an ordinal inscription.",
1476+
style: STextStyles.smallMed12(context).copyWith(
1477+
color: Theme.of(
1478+
context,
1479+
).extension<StackColors>()!.warningForeground,
1480+
),
1481+
),
1482+
),
1483+
],
1484+
),
1485+
),
1486+
);
1487+
},
1488+
),
14211489
SizedBox(height: isDesktop ? 28 : 16),
14221490
Padding(
14231491
padding: isDesktop

0 commit comments

Comments
 (0)