Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/electrumx_rpc/electrumx_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ class ElectrumXClient {
}
}

/// Returns the txids of the current transactions found in the mempool
/// Returns the txids of the current spark transactions found in the mempool
Future<Set<String>> getMempoolTxids({String? requestID}) async {
try {
final start = DateTime.now();
Expand Down Expand Up @@ -1089,6 +1089,7 @@ class ElectrumXClient {
// the space after lTags is required lol
lTags: List<String>.from(entry.value["lTags "] as List),
coins: List<String>.from(entry.value["coins"] as List),
isLocked: entry.value["isLocked"] as bool,
),
);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/models/electrumx_response/spark_models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ class SparkMempoolData {
final List<String> serialContext;
final List<String> lTags;
final List<String> coins;
final bool isLocked;

SparkMempoolData({
required this.txid,
required this.serialContext,
required this.lTags,
required this.coins,
required this.isLocked,
});

@override
Expand All @@ -17,7 +19,8 @@ class SparkMempoolData {
"txid: $txid, "
"serialContext: $serialContext, "
"lTags: $lTags, "
"coins: $coins"
"coins: $coins, "
"isLocked: $isLocked"
"}";
}
}
Expand Down
36 changes: 29 additions & 7 deletions lib/pages/spark_names/buy_spark_name_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import '../../utilities/assets.dart';
import '../../utilities/constants.dart';
import '../../utilities/show_loading.dart';
import '../../utilities/text_styles.dart';
import '../../wallets/crypto_currency/coins/firo.dart';
import '../../wallets/isar/providers/wallet_info_provider.dart';
import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
import '../../widgets/background.dart';
Expand Down Expand Up @@ -59,6 +60,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
String get _title => isRenewal ? "Renew name" : "Buy name";

int _years = 1;
late bool _buttonEnabled;

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

Future<TxData> _preRegFuture() async {
final chosenAddress = addressController.text;

if (chosenAddress.isEmpty) {
throw Exception(
"Please select the Spark address you want to link to your Spark Name",
);
}

final wallet =
ref.read(pWallets).getWallet(widget.walletId) as SparkInterface;

if (!(wallet.cryptoCurrency as Firo).validateSparkAddress(chosenAddress)) {
throw Exception("Invalid Spark address selected");
}

final myAddresses =
await wallet.mainDB.isar.addresses
.where()
Expand All @@ -94,10 +108,8 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
.valueProperty()
.findAll();

final chosenAddress = addressController.text;

if (!myAddresses.contains(chosenAddress)) {
throw Exception("Address does not belong to this wallet");
throw Exception("Selected Spark address does not belong to this wallet");
}

final txData = await wallet.prepareSparkNameTransaction(
Expand Down Expand Up @@ -174,10 +186,19 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
@override
void initState() {
super.initState();

if (isRenewal) {
additionalInfoController.text = widget.nameToRenew!.additionalInfo ?? "";
addressController.text = widget.nameToRenew!.address;
}
_buttonEnabled = addressController.text.isNotEmpty;
addressController.addListener(() {
if (mounted) {
setState(() {
_buttonEnabled = addressController.text.isNotEmpty;
});
}
});
}

@override
Expand Down Expand Up @@ -274,7 +295,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"Address",
"Spark address",
style:
Util.isDesktop
? STextStyles.w500_14(context).copyWith(
Expand Down Expand Up @@ -311,7 +332,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
isDense: true,
contentPadding: const EdgeInsets.all(16),
hintStyle: STextStyles.fieldLabel(context),
hintText: "Address",
hintText: "Spark address (required)",
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
Expand Down Expand Up @@ -360,7 +381,7 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
isDense: true,
contentPadding: const EdgeInsets.all(16),
hintStyle: STextStyles.fieldLabel(context),
hintText: "Additional info",
hintText: "Additional info (optional)",
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
Expand Down Expand Up @@ -516,7 +537,8 @@ class _BuySparkNameViewState extends ConsumerState<BuySparkNameView> {
PrimaryButton(
label: isRenewal ? "Renew" : "Buy",
buttonHeight: Util.isDesktop ? ButtonHeight.l : null,
onPressed: _prepareNameTx,
enabled: _buttonEnabled,
onPressed: _buttonEnabled ? _prepareNameTx : null,
),
SizedBox(height: Util.isDesktop ? 32 : 16),
],
Expand Down
23 changes: 12 additions & 11 deletions lib/pages/wallet_view/wallet_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1060,13 +1060,25 @@ class _WalletViewState extends ConsumerState<WalletView> {
),
if (Constants.enableExchange &&
ref.watch(pWalletCoin(walletId)) is! FrostCurrency &&
wallet is! FiroWallet &&
AppConfig.hasFeature(AppFeature.buy) &&
showExchange)
WalletNavigationBarItemData(
label: "Buy",
icon: const BuyNavIcon(),
onTap: () => _onBuyPressed(context),
),
if (wallet is SparkInterface)
WalletNavigationBarItemData(
label: "Names",
icon: const PaynymNavIcon(),
onTap: () {
Navigator.of(context).pushNamed(
SparkNamesHomeView.routeName,
arguments: widget.walletId,
);
},
),
],
moreItems: [
if (ref.watch(
Expand Down Expand Up @@ -1153,17 +1165,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
);
},
),
if (wallet is SparkInterface)
WalletNavigationBarItemData(
label: "Names",
icon: const PaynymNavIcon(),
onTap: () {
Navigator.of(context).pushNamed(
SparkNamesHomeView.routeName,
arguments: widget.walletId,
);
},
),
if (!viewOnly && wallet is PaynymInterface)
WalletNavigationBarItemData(
label: "PayNym",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
Assets.svg.recycle,
_onAnonymizeAllPressed,
),

if (wallet is SparkInterface)
(WalletFeature.sparkNames, Assets.svg.robotHead, _onSparkNamesPressed),

if (!isViewOnly &&
Constants.enableExchange &&
AppConfig.hasFeature(AppFeature.swap) &&
Expand All @@ -412,9 +416,6 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {
if (showExchange && AppConfig.hasFeature(AppFeature.buy))
(WalletFeature.buy, Assets.svg.swap, _onBuyPressed),

if (wallet is SparkInterface)
(WalletFeature.sparkNames, Assets.svg.robotHead, _onSparkNamesPressed),

if (showCoinControl)
(
WalletFeature.coinControl,
Expand Down Expand Up @@ -463,9 +464,10 @@ class _DesktopWalletFeaturesState extends ConsumerState<DesktopWalletFeatures> {

final options = _getOptions(
wallet,
ref.watch(
prefsChangeNotifierProvider.select((value) => value.enableExchange),
),
wallet is! FiroWallet &&
ref.watch(
prefsChangeNotifierProvider.select((value) => value.enableExchange),
),
(wallet is CoinControlInterface &&
ref.watch(
prefsChangeNotifierProvider.select(
Expand Down
63 changes: 25 additions & 38 deletions lib/pages_desktop_specific/spark_coins/spark_coins_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import '../../widgets/desktop/desktop_scaffold.dart';
import '../../widgets/isar_collection_watcher_list.dart';

class SparkCoinsView extends ConsumerWidget {
const SparkCoinsView({
super.key,
required this.walletId,
});
const SparkCoinsView({super.key, required this.walletId});

static const title = "Spark coins";
static const String routeName = "/sparkCoinsView";
Expand All @@ -47,43 +44,35 @@ class SparkCoinsView extends ConsumerWidget {
leading: Expanded(
child: Row(
children: [
const SizedBox(
width: 32,
),
const SizedBox(width: 32),
AppBarIconButton(
size: 32,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
color:
Theme.of(
context,
).extension<StackColors>()!.textFieldDefaultBG,
shadows: const [],
icon: SvgPicture.asset(
Assets.svg.arrowLeft,
width: 18,
height: 18,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
color:
Theme.of(
context,
).extension<StackColors>()!.topNavIconPrimary,
),
onPressed: Navigator.of(context).pop,
),
const SizedBox(
width: 12,
),
Text(
title,
style: STextStyles.desktopH3(context),
),
const SizedBox(width: 12),
Text(title, style: STextStyles.desktopH3(context)),
const Spacer(),
],
),
),
useSpacers: false,
isCompactHeight: true,
),
body: Padding(
padding: const EdgeInsets.all(24),
child: child,
),
body: Padding(padding: const EdgeInsets.all(24), child: child),
);
},
child: ConditionalParent(
Expand All @@ -98,26 +87,23 @@ class SparkCoinsView extends ConsumerWidget {
leading: AppBarBackButton(
onPressed: () => Navigator.of(context).pop(),
),
title: Text(
title,
style: STextStyles.navBarTitle(context),
),
),
body: SafeArea(
child: child,
title: Text(title, style: STextStyles.navBarTitle(context)),
),
body: SafeArea(child: child),
),
);
},
child: IsarCollectionWatcherList(
itemName: title,
queryBuilder: () => ref
.read(mainDBProvider)
.isar
.sparkCoins
.where()
.walletIdEqualToAnyLTagHash(walletId)
.sortByHeightDesc(),
queryBuilder:
() =>
ref
.read(mainDBProvider)
.isar
.sparkCoins
.where()
.walletIdEqualToAnyLTagHash(walletId)
.sortByHeightDesc(),
itemBuilder: (SparkCoin? coin) {
return [
("TXID", coin?.txHash ?? "", 9),
Expand All @@ -129,6 +115,7 @@ class SparkCoinsView extends ConsumerWidget {
("Group ID", coin?.groupId.toString() ?? "", 2),
("Type", coin?.type.name ?? "", 2),
("Used", coin?.isUsed.toString() ?? "", 2),
("Locked", coin?.isLocked.toString() ?? "", 2),
];
},
),
Expand Down
2 changes: 1 addition & 1 deletion lib/wallets/crypto_currency/coins/banano.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Banano extends NanoCurrency {
Uri defaultBlockExplorer(String txid) {
switch (network) {
case CryptoCurrencyNetwork.main:
return Uri.parse("https://www.bananolooker.com/block/$txid");
return Uri.parse("https://creeper.banano.cc/hash/$txid");
default:
throw Exception(
"Unsupported network for defaultBlockExplorer(): $network",
Expand Down
2 changes: 1 addition & 1 deletion lib/wallets/crypto_currency/coins/nano.dart
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Nano extends NanoCurrency {
Uri defaultBlockExplorer(String txid) {
switch (network) {
case CryptoCurrencyNetwork.main:
return Uri.parse("https://www.nanolooker.com/block/$txid");
return Uri.parse("https://nanexplorer.com/nano/blocks/$txid");
default:
throw Exception(
"Unsupported network for defaultBlockExplorer(): $network",
Expand Down
Loading
Loading