Skip to content

Commit 9604f13

Browse files
Merge pull request #1163 from cypherstack/firo-tweaks
Firo tweaks
2 parents 9850049 + 8993560 commit 9604f13

File tree

11 files changed

+170
-78
lines changed

11 files changed

+170
-78
lines changed

lib/electrumx_rpc/electrumx_client.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ class ElectrumXClient {
10361036
}
10371037
}
10381038

1039-
/// Returns the txids of the current transactions found in the mempool
1039+
/// Returns the txids of the current spark transactions found in the mempool
10401040
Future<Set<String>> getMempoolTxids({String? requestID}) async {
10411041
try {
10421042
final start = DateTime.now();
@@ -1089,6 +1089,7 @@ class ElectrumXClient {
10891089
// the space after lTags is required lol
10901090
lTags: List<String>.from(entry.value["lTags "] as List),
10911091
coins: List<String>.from(entry.value["coins"] as List),
1092+
isLocked: entry.value["isLocked"] as bool,
10921093
),
10931094
);
10941095
}

lib/models/electrumx_response/spark_models.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ class SparkMempoolData {
33
final List<String> serialContext;
44
final List<String> lTags;
55
final List<String> coins;
6+
final bool isLocked;
67

78
SparkMempoolData({
89
required this.txid,
910
required this.serialContext,
1011
required this.lTags,
1112
required this.coins,
13+
required this.isLocked,
1214
});
1315

1416
@override
@@ -17,7 +19,8 @@ class SparkMempoolData {
1719
"txid: $txid, "
1820
"serialContext: $serialContext, "
1921
"lTags: $lTags, "
20-
"coins: $coins"
22+
"coins: $coins, "
23+
"isLocked: $isLocked"
2124
"}";
2225
}
2326
}

lib/pages/spark_names/buy_spark_name_view.dart

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import '../../utilities/assets.dart';
2323
import '../../utilities/constants.dart';
2424
import '../../utilities/show_loading.dart';
2525
import '../../utilities/text_styles.dart';
26+
import '../../wallets/crypto_currency/coins/firo.dart';
2627
import '../../wallets/isar/providers/wallet_info_provider.dart';
2728
import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
2829
import '../../widgets/background.dart';
@@ -59,6 +60,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
5960
String get _title => isRenewal ? "Renew name" : "Buy name";
6061

6162
int _years = 1;
63+
late bool _buttonEnabled;
6264

6365
bool _lockAddressFill = false;
6466
Future<void> _fillCurrentReceiving() async {
@@ -80,9 +82,21 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
8082
}
8183

8284
Future<TxData> _preRegFuture() async {
85+
final chosenAddress = addressController.text;
86+
87+
if (chosenAddress.isEmpty) {
88+
throw Exception(
89+
"Please select the Spark address you want to link to your Spark Name",
90+
);
91+
}
92+
8393
final wallet =
8494
ref.read(pWallets).getWallet(widget.walletId) as SparkInterface;
8595

96+
if (!(wallet.cryptoCurrency as Firo).validateSparkAddress(chosenAddress)) {
97+
throw Exception("Invalid Spark address selected");
98+
}
99+
86100
final myAddresses =
87101
await wallet.mainDB.isar.addresses
88102
.where()
@@ -94,10 +108,8 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
94108
.valueProperty()
95109
.findAll();
96110

97-
final chosenAddress = addressController.text;
98-
99111
if (!myAddresses.contains(chosenAddress)) {
100-
throw Exception("Address does not belong to this wallet");
112+
throw Exception("Selected Spark address does not belong to this wallet");
101113
}
102114

103115
final txData = await wallet.prepareSparkNameTransaction(
@@ -174,10 +186,19 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
174186
@override
175187
void initState() {
176188
super.initState();
189+
177190
if (isRenewal) {
178191
additionalInfoController.text = widget.nameToRenew!.additionalInfo ?? "";
179192
addressController.text = widget.nameToRenew!.address;
180193
}
194+
_buttonEnabled = addressController.text.isNotEmpty;
195+
addressController.addListener(() {
196+
if (mounted) {
197+
setState(() {
198+
_buttonEnabled = addressController.text.isNotEmpty;
199+
});
200+
}
201+
});
181202
}
182203

183204
@override
@@ -274,7 +295,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
274295
mainAxisAlignment: MainAxisAlignment.spaceBetween,
275296
children: [
276297
Text(
277-
"Address",
298+
"Spark address",
278299
style:
279300
Util.isDesktop
280301
? STextStyles.w500_14(context).copyWith(
@@ -311,7 +332,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
311332
isDense: true,
312333
contentPadding: const EdgeInsets.all(16),
313334
hintStyle: STextStyles.fieldLabel(context),
314-
hintText: "Address",
335+
hintText: "Spark address (required)",
315336
border: InputBorder.none,
316337
enabledBorder: InputBorder.none,
317338
focusedBorder: InputBorder.none,
@@ -360,7 +381,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
360381
isDense: true,
361382
contentPadding: const EdgeInsets.all(16),
362383
hintStyle: STextStyles.fieldLabel(context),
363-
hintText: "Additional info",
384+
hintText: "Additional info (optional)",
364385
border: InputBorder.none,
365386
enabledBorder: InputBorder.none,
366387
focusedBorder: InputBorder.none,
@@ -516,7 +537,8 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
516537
PrimaryButton(
517538
label: isRenewal ? "Renew" : "Buy",
518539
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
519-
onPressed: _prepareNameTx,
540+
enabled: _buttonEnabled,
541+
onPressed: _buttonEnabled ? _prepareNameTx : null,
520542
),
521543
SizedBox(height: Util.isDesktop ? 32 : 16),
522544
],

lib/pages/wallet_view/wallet_view.dart

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,13 +1060,25 @@ class _WalletViewState extends ConsumerState<WalletView> {
10601060
),
10611061
if (Constants.enableExchange &&
10621062
ref.watch(pWalletCoin(walletId)) is! FrostCurrency &&
1063+
wallet is! FiroWallet &&
10631064
AppConfig.hasFeature(AppFeature.buy) &&
10641065
showExchange)
10651066
WalletNavigationBarItemData(
10661067
label: "Buy",
10671068
icon: const BuyNavIcon(),
10681069
onTap: () => _onBuyPressed(context),
10691070
),
1071+
if (wallet is SparkInterface)
1072+
WalletNavigationBarItemData(
1073+
label: "Names",
1074+
icon: const PaynymNavIcon(),
1075+
onTap: () {
1076+
Navigator.of(context).pushNamed(
1077+
SparkNamesHomeView.routeName,
1078+
arguments: widget.walletId,
1079+
);
1080+
},
1081+
),
10701082
],
10711083
moreItems: [
10721084
if (ref.watch(
@@ -1153,17 +1165,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
11531165
);
11541166
},
11551167
),
1156-
if (wallet is SparkInterface)
1157-
WalletNavigationBarItemData(
1158-
label: "Names",
1159-
icon: const PaynymNavIcon(),
1160-
onTap: () {
1161-
Navigator.of(context).pushNamed(
1162-
SparkNamesHomeView.routeName,
1163-
arguments: widget.walletId,
1164-
);
1165-
},
1166-
),
11671168
if (!viewOnly && wallet is PaynymInterface)
11681169
WalletNavigationBarItemData(
11691170
label: "PayNym",

lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
403403
Assets.svg.recycle,
404404
_onAnonymizeAllPressed,
405405
),
406+
407+
if (wallet is SparkInterface)
408+
(WalletFeature.sparkNames, Assets.svg.robotHead, _onSparkNamesPressed),
409+
406410
if (!isViewOnly &&
407411
Constants.enableExchange &&
408412
AppConfig.hasFeature(AppFeature.swap) &&
@@ -412,9 +416,6 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
412416
if (showExchange && AppConfig.hasFeature(AppFeature.buy))
413417
(WalletFeature.buy, Assets.svg.swap, _onBuyPressed),
414418

415-
if (wallet is SparkInterface)
416-
(WalletFeature.sparkNames, Assets.svg.robotHead, _onSparkNamesPressed),
417-
418419
if (showCoinControl)
419420
(
420421
WalletFeature.coinControl,
@@ -463,9 +464,10 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
463464

464465
final options = _getOptions(
465466
wallet,
466-
ref.watch(
467-
prefsChangeNotifierProvider.select((value) => value.enableExchange),
468-
),
467+
wallet is! FiroWallet &&
468+
ref.watch(
469+
prefsChangeNotifierProvider.select((value) => value.enableExchange),
470+
),
469471
(wallet is CoinControlInterface &&
470472
ref.watch(
471473
prefsChangeNotifierProvider.select(

lib/pages_desktop_specific/spark_coins/spark_coins_view.dart

Lines changed: 25 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ import '../../widgets/desktop/desktop_scaffold.dart';
2626
import '../../widgets/isar_collection_watcher_list.dart';
2727

2828
class SparkCoinsView extends ConsumerWidget {
29-
const SparkCoinsView({
30-
super.key,
31-
required this.walletId,
32-
});
29+
const SparkCoinsView({super.key, required this.walletId});
3330

3431
static const title = "Spark coins";
3532
static const String routeName = "/sparkCoinsView";
@@ -47,43 +44,35 @@ class SparkCoinsView extends ConsumerWidget {
4744
leading: Expanded(
4845
child: Row(
4946
children: [
50-
const SizedBox(
51-
width: 32,
52-
),
47+
const SizedBox(width: 32),
5348
AppBarIconButton(
5449
size: 32,
55-
color: Theme.of(context)
56-
.extension<StackColors>()!
57-
.textFieldDefaultBG,
50+
color:
51+
Theme.of(
52+
context,
53+
).extension<StackColors>()!.textFieldDefaultBG,
5854
shadows: const [],
5955
icon: SvgPicture.asset(
6056
Assets.svg.arrowLeft,
6157
width: 18,
6258
height: 18,
63-
color: Theme.of(context)
64-
.extension<StackColors>()!
65-
.topNavIconPrimary,
59+
color:
60+
Theme.of(
61+
context,
62+
).extension<StackColors>()!.topNavIconPrimary,
6663
),
6764
onPressed: Navigator.of(context).pop,
6865
),
69-
const SizedBox(
70-
width: 12,
71-
),
72-
Text(
73-
title,
74-
style: STextStyles.desktopH3(context),
75-
),
66+
const SizedBox(width: 12),
67+
Text(title, style: STextStyles.desktopH3(context)),
7668
const Spacer(),
7769
],
7870
),
7971
),
8072
useSpacers: false,
8173
isCompactHeight: true,
8274
),
83-
body: Padding(
84-
padding: const EdgeInsets.all(24),
85-
child: child,
86-
),
75+
body: Padding(padding: const EdgeInsets.all(24), child: child),
8776
);
8877
},
8978
child: ConditionalParent(
@@ -98,26 +87,23 @@ class SparkCoinsView extends ConsumerWidget {
9887
leading: AppBarBackButton(
9988
onPressed: () => Navigator.of(context).pop(),
10089
),
101-
title: Text(
102-
title,
103-
style: STextStyles.navBarTitle(context),
104-
),
105-
),
106-
body: SafeArea(
107-
child: child,
90+
title: Text(title, style: STextStyles.navBarTitle(context)),
10891
),
92+
body: SafeArea(child: child),
10993
),
11094
);
11195
},
11296
child: IsarCollectionWatcherList(
11397
itemName: title,
114-
queryBuilder: () => ref
115-
.read(mainDBProvider)
116-
.isar
117-
.sparkCoins
118-
.where()
119-
.walletIdEqualToAnyLTagHash(walletId)
120-
.sortByHeightDesc(),
98+
queryBuilder:
99+
() =>
100+
ref
101+
.read(mainDBProvider)
102+
.isar
103+
.sparkCoins
104+
.where()
105+
.walletIdEqualToAnyLTagHash(walletId)
106+
.sortByHeightDesc(),
121107
itemBuilder: (SparkCoin? coin) {
122108
return [
123109
("TXID", coin?.txHash ?? "", 9),
@@ -129,6 +115,7 @@ class SparkCoinsView extends ConsumerWidget {
129115
("Group ID", coin?.groupId.toString() ?? "", 2),
130116
("Type", coin?.type.name ?? "", 2),
131117
("Used", coin?.isUsed.toString() ?? "", 2),
118+
("Locked", coin?.isLocked.toString() ?? "", 2),
132119
];
133120
},
134121
),

lib/wallets/crypto_currency/coins/banano.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Banano extends NanoCurrency {
8989
Uri defaultBlockExplorer(String txid) {
9090
switch (network) {
9191
case CryptoCurrencyNetwork.main:
92-
return Uri.parse("https://www.bananolooker.com/block/$txid");
92+
return Uri.parse("https://creeper.banano.cc/hash/$txid");
9393
default:
9494
throw Exception(
9595
"Unsupported network for defaultBlockExplorer(): $network",

lib/wallets/crypto_currency/coins/nano.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class Nano extends NanoCurrency {
9595
Uri defaultBlockExplorer(String txid) {
9696
switch (network) {
9797
case CryptoCurrencyNetwork.main:
98-
return Uri.parse("https://www.nanolooker.com/block/$txid");
98+
return Uri.parse("https://nanexplorer.com/nano/blocks/$txid");
9999
default:
100100
throw Exception(
101101
"Unsupported network for defaultBlockExplorer(): $network",

0 commit comments

Comments
 (0)