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
31 changes: 25 additions & 6 deletions lib/pages/send_view/confirm_transaction_view.dart
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart';
import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart';
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/route_generator.dart';
import 'package:stackwallet/services/coins/epiccash/epiccash_wallet.dart';
import 'package:stackwallet/utilities/cfcolors.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/flush_bar_type.dart';
import 'package:stackwallet/utilities/format.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
Expand DownExpand Up@@ -40,38 +45,52 @@ class _ConfirmTransactionViewState
late final String routeOnSuccessName;

Future<void> _attemptSend(BuildContext context) async {
showDialog<dynamic>(
unawaited(showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: false,
builder: (context) {
return const SendingTransactionDialog();
},
);
));

final note = transactionInfo["note"] as String? ?? "";
final manager =
ref.read(walletsChangeNotifierProvider).getManager(walletId);

try {
final txid = await manager.confirmSend(txData: transactionInfo);
manager.refresh();
unawaited(manager.refresh());

// save note
ref
await ref
.read(notesServiceChangeNotifierProvider(walletId))
.editOrAddNote(txid: txid, note: note);

// pop back to wallet
if (mounted) {
Navigator.of(context).popUntil(ModalRoute.withName(routeOnSuccessName));
}
} on BadEpicHttpAddressException catch (_) {
if (mounted) {
// pop building dialog
Navigator.of(context).pop();
unawaited(
showFloatingFlushBar(
type: FlushBarType.warning,
message:
"Connection failed. Please check the address and try again.",
context: context,
),
);
return;
}
} catch (e, s) {
debugPrint("$e\n$s");
// pop sending dialog
Navigator.of(context).pop();

showDialog<void>(
await showDialog<void>(
context: context,
useSafeArea: false,
barrierDismissible: true,
Expand DownExpand Up@@ -316,7 +335,7 @@ class _ConfirmTransactionViewState
);

if (unlocked is bool && unlocked && mounted) {
_attemptSend(context);
unawaited(_attemptSend(context));
}
},
child: Text(
Expand Down
14 changes: 8 additions & 6 deletions lib/pages/send_view/send_view.dart
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:decimal/decimal.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand DownExpand Up@@ -1175,7 +1177,7 @@ class _SendViewState extends ConsumerState<SendView> {
try {
bool wasCancelled = false;

showDialog<dynamic>(
unawaited(showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: false,
Expand All@@ -1188,7 +1190,7 @@ class _SendViewState extends ConsumerState<SendView> {
},
);
},
);
));

final txData = await manager.prepareSend(
address: _address!,
Expand All@@ -1205,7 +1207,7 @@ class _SendViewState extends ConsumerState<SendView> {
txData["note"] = noteController.text;
txData["address"] = _address;

Navigator.of(context).push(
unawaited(Navigator.of(context).push(
RouteGenerator.getRoute(
shouldUseMaterialRoute: RouteGenerator
.useMaterialPageRoute,
Expand All@@ -1219,14 +1221,14 @@ class _SendViewState extends ConsumerState<SendView> {
.routeName,
),
),
);
));
}
} catch (e) {
if (mounted) {
// pop building dialog
Navigator.of(context).pop();

showDialog<dynamic>(
unawaited(showDialog<dynamic>(
context: context,
useSafeArea: false,
barrierDismissible: true,
Expand DownExpand Up@@ -1258,7 +1260,7 @@ class _SendViewState extends ConsumerState<SendView> {
),
);
},
);
));
}
}
}
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/models/exchange/exchange_form_state.dart';
import 'package:stackwallet/models/exchange/estimated_rate_exchange_form_state.dart';

final estimatedRateExchangeFormProvider =
ChangeNotifierProvider((ref) => EstimatedRateExchangeFormState());
21 changes: 21 additions & 0 deletions lib/services/coins/epiccash/epiccash_wallet.dart
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,17 @@ const int MINIMUM_CONFIRMATIONS = 10;
const String GENESIS_HASH_MAINNET = "";
const String GENESIS_HASH_TESTNET = "";

class BadEpicHttpAddressException implements Exception {
final String? message;

BadEpicHttpAddressException({this.message});

@override
String toString() {
return "BadEpicHttpAddressException: $message";
}
}

// isolate

Map<ReceivePort, Isolate> isolates = {};
Expand DownExpand Up@@ -754,6 +765,10 @@ class EpicCashWallet extends CoinServiceAPI {
}, name: walletName);

message = await receivePort.first;

// TODO: throw BadEpicHttpAddressException in the case where a send fails due to bad http address
// throw BadEpicHttpAddressException();

if (message is String) {
Logging.instance
.log("this is a string $message", level: LogLevel.Error);
Expand DownExpand Up@@ -2235,6 +2250,12 @@ class EpicCashWallet extends CoinServiceAPI {

@override
bool validateAddress(String address) {
if (address.startsWith("http://") || address.startsWith("https://")) {
if (Uri.tryParse(address) != null) {
return true;
}
}

String validate = validateSendAddress(address);
if (int.parse(validate) == 1) {
return true;
Expand Down