mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-11 05:04:35 +00:00
Merge remote-tracking branch 'origin/staging' into add-ethereum
# Conflicts: # lib/utilities/show_loading.dart
This commit is contained in:
commit
24904f3476
17 changed files with 240 additions and 178 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit e81b1b7c2d8114435a9458ab2e439f4393f626e7
|
Subproject commit e62cfc2cae093346bd547ed1379f99c1ed1fe537
|
|
@ -2,9 +2,7 @@ import 'package:decimal/decimal.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
import 'package:stackwallet/models/exchange/aggregate_currency.dart';
|
||||||
import 'package:stackwallet/models/exchange/response_objects/estimate.dart';
|
import 'package:stackwallet/models/exchange/response_objects/estimate.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
|
||||||
import 'package:stackwallet/services/exchange/exchange.dart';
|
import 'package:stackwallet/services/exchange/exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
|
||||||
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
|
||||||
|
@ -325,28 +323,28 @@ class ExchangeFormState extends ChangeNotifier {
|
||||||
required bool shouldNotifyListeners,
|
required bool shouldNotifyListeners,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
switch (exchange.name) {
|
// switch (exchange.name) {
|
||||||
case ChangeNowExchange.exchangeName:
|
// case ChangeNowExchange.exchangeName:
|
||||||
if (!_exchangeSupported(
|
// if (!_exchangeSupported(
|
||||||
exchangeName: exchange.name,
|
// exchangeName: exchange.name,
|
||||||
sendCurrency: sendCurrency,
|
// sendCurrency: sendCurrency,
|
||||||
receiveCurrency: receiveCurrency,
|
// receiveCurrency: receiveCurrency,
|
||||||
exchangeRateType: exchangeRateType,
|
// exchangeRateType: exchangeRateType,
|
||||||
)) {
|
// )) {
|
||||||
_exchange = MajesticBankExchange.instance;
|
// _exchange = MajesticBankExchange.instance;
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
case MajesticBankExchange.exchangeName:
|
// case MajesticBankExchange.exchangeName:
|
||||||
if (!_exchangeSupported(
|
// if (!_exchangeSupported(
|
||||||
exchangeName: exchange.name,
|
// exchangeName: exchange.name,
|
||||||
sendCurrency: sendCurrency,
|
// sendCurrency: sendCurrency,
|
||||||
receiveCurrency: receiveCurrency,
|
// receiveCurrency: receiveCurrency,
|
||||||
exchangeRateType: exchangeRateType,
|
// exchangeRateType: exchangeRateType,
|
||||||
)) {
|
// )) {
|
||||||
_exchange = ChangeNowExchange.instance;
|
// _exchange = ChangeNowExchange.instance;
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
await _updateRanges(shouldNotifyListeners: false);
|
await _updateRanges(shouldNotifyListeners: false);
|
||||||
await _updateEstimate(shouldNotifyListeners: false);
|
await _updateEstimate(shouldNotifyListeners: false);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import 'package:stackwallet/models/isar/exchange_cache/pair.dart';
|
||||||
import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart';
|
import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart';
|
||||||
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart';
|
||||||
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
|
@ -95,11 +94,12 @@ class _ExchangeCurrencySelectionViewState
|
||||||
if (widget.pairedTicker == null) {
|
if (widget.pairedTicker == null) {
|
||||||
return await _getCurrencies();
|
return await _getCurrencies();
|
||||||
}
|
}
|
||||||
List<Currency> currencies = await ExchangeDataLoadingService
|
List<Currency> currencies = [];
|
||||||
.instance.isar.currencies
|
// await ExchangeDataLoadingService
|
||||||
.where()
|
// .instance.isar.currencies
|
||||||
.exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
// .where()
|
||||||
.findAll();
|
// .exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
||||||
|
// .findAll();
|
||||||
|
|
||||||
final cn = await ChangeNowExchange.instance.getPairedCurrencies(
|
final cn = await ChangeNowExchange.instance.getPairedCurrencies(
|
||||||
widget.pairedTicker!,
|
widget.pairedTicker!,
|
||||||
|
|
|
@ -579,7 +579,7 @@ class _Step4ViewState extends ConsumerState<Step4View> {
|
||||||
time,
|
time,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
final txData = results.last
|
final txData = results.first
|
||||||
as Map<String, dynamic>;
|
as Map<String, dynamic>;
|
||||||
|
|
||||||
if (!wasCancelled) {
|
if (!wasCancelled) {
|
||||||
|
|
|
@ -71,11 +71,12 @@ class _ExchangeProviderOptionsState
|
||||||
sendCurrency: sendCurrency,
|
sendCurrency: sendCurrency,
|
||||||
receiveCurrency: receivingCurrency,
|
receiveCurrency: receivingCurrency,
|
||||||
);
|
);
|
||||||
final showMajesticBank = exchangeSupported(
|
final showMajesticBank = false;
|
||||||
exchangeName: MajesticBankExchange.exchangeName,
|
// exchangeSupported(
|
||||||
sendCurrency: sendCurrency,
|
// exchangeName: MajesticBankExchange.exchangeName,
|
||||||
receiveCurrency: receivingCurrency,
|
// sendCurrency: sendCurrency,
|
||||||
);
|
// receiveCurrency: receivingCurrency,
|
||||||
|
// );
|
||||||
|
|
||||||
return RoundedWhiteContainer(
|
return RoundedWhiteContainer(
|
||||||
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),
|
padding: isDesktop ? const EdgeInsets.all(0) : const EdgeInsets.all(12),
|
||||||
|
|
|
@ -93,7 +93,8 @@ class _TradeDetailsViewState extends ConsumerState<TradeDetailsView> {
|
||||||
.trades
|
.trades
|
||||||
.firstWhere((e) => e.tradeId == tradeId);
|
.firstWhere((e) => e.tradeId == tradeId);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted &&
|
||||||
|
trade.exchangeName != MajesticBankExchange.exchangeName) {
|
||||||
final exchange = Exchange.fromName(trade.exchangeName);
|
final exchange = Exchange.fromName(trade.exchangeName);
|
||||||
final response = await exchange.updateTrade(trade);
|
final response = await exchange.updateTrade(trade);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,9 @@ import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/biometrics.dart';
|
import 'package:stackwallet/utilities/biometrics.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
|
||||||
|
import 'package:stackwallet/utilities/show_loading.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -80,19 +82,47 @@ class _LockscreenViewState extends ConsumerState<LockscreenView> {
|
||||||
if (widget.popOnSuccess) {
|
if (widget.popOnSuccess) {
|
||||||
Navigator.of(context).pop(widget.routeOnSuccessArguments);
|
Navigator.of(context).pop(widget.routeOnSuccessArguments);
|
||||||
} else {
|
} else {
|
||||||
unawaited(Navigator.of(context).pushReplacementNamed(
|
final loadIntoWallet = widget.routeOnSuccess == HomeView.routeName &&
|
||||||
widget.routeOnSuccess,
|
widget.routeOnSuccessArguments is String;
|
||||||
arguments: widget.routeOnSuccessArguments,
|
|
||||||
));
|
if (loadIntoWallet) {
|
||||||
if (widget.routeOnSuccess == HomeView.routeName &&
|
|
||||||
widget.routeOnSuccessArguments is String) {
|
|
||||||
final walletId = widget.routeOnSuccessArguments as String;
|
final walletId = widget.routeOnSuccessArguments as String;
|
||||||
unawaited(Navigator.of(context).pushNamed(WalletView.routeName,
|
|
||||||
arguments: Tuple2(
|
final manager =
|
||||||
|
ref.read(walletsChangeNotifierProvider).getManager(walletId);
|
||||||
|
if (manager.coin == Coin.monero || manager.coin == Coin.wownero) {
|
||||||
|
await showLoading(
|
||||||
|
opaqueBG: true,
|
||||||
|
whileFuture: manager.initializeExisting(),
|
||||||
|
context: context,
|
||||||
|
message: "Loading ${manager.coin.prettyName} wallet...",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mounted) {
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).pushReplacementNamed(
|
||||||
|
widget.routeOnSuccess,
|
||||||
|
arguments: widget.routeOnSuccessArguments,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if (loadIntoWallet) {
|
||||||
|
final walletId = widget.routeOnSuccessArguments as String;
|
||||||
|
|
||||||
|
unawaited(
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
WalletView.routeName,
|
||||||
|
arguments: Tuple2(
|
||||||
walletId,
|
walletId,
|
||||||
ref
|
ref
|
||||||
.read(walletsChangeNotifierProvider)
|
.read(walletsChangeNotifierProvider)
|
||||||
.getManagerProvider(walletId))));
|
.getManagerProvider(walletId),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_native_splash/cli_commands.dart';
|
import 'package:flutter_native_splash/cli_commands.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
|
|
||||||
class AddressTag extends StatelessWidget {
|
class AddressTag extends StatelessWidget {
|
||||||
|
@ -16,10 +17,12 @@ class AddressTag extends StatelessWidget {
|
||||||
vertical: 5,
|
vertical: 5,
|
||||||
horizontal: 7,
|
horizontal: 7,
|
||||||
),
|
),
|
||||||
color: Colors.black,
|
color: Theme.of(context).extension<StackColors>()!.buttonBackPrimary,
|
||||||
child: Text(
|
child: Text(
|
||||||
tag.capitalize(),
|
tag.capitalize(),
|
||||||
style: STextStyles.w500_14(context),
|
style: STextStyles.w500_14(context).copyWith(
|
||||||
|
color: Theme.of(context).extension<StackColors>()!.buttonTextPrimary,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,44 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
late bool saveEnabled;
|
late bool saveEnabled;
|
||||||
late bool testConnectionEnabled;
|
late bool testConnectionEnabled;
|
||||||
|
|
||||||
|
Future<bool> _xmrHelper(String url, int? port) async {
|
||||||
|
final uri = Uri.parse(url);
|
||||||
|
|
||||||
|
final String path = uri.path.isEmpty ? "/json_rpc" : uri.path;
|
||||||
|
|
||||||
|
final uriString = "${uri.scheme}://${uri.host}:${port ?? 0}$path";
|
||||||
|
|
||||||
|
ref.read(nodeFormDataProvider).useSSL = true;
|
||||||
|
|
||||||
|
final response = await testMoneroNodeConnection(
|
||||||
|
Uri.parse(uriString),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (response.cert != null) {
|
||||||
|
if (mounted) {
|
||||||
|
final shouldAllowBadCert = await showBadX509CertificateDialog(
|
||||||
|
response.cert!,
|
||||||
|
response.url!,
|
||||||
|
response.port!,
|
||||||
|
context,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (shouldAllowBadCert) {
|
||||||
|
final response =
|
||||||
|
await testMoneroNodeConnection(Uri.parse(uriString), true);
|
||||||
|
ref.read(nodeFormDataProvider).host = url;
|
||||||
|
return response.success;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ref.read(nodeFormDataProvider).host = url;
|
||||||
|
return response.success;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Future<bool> _testConnection({bool showFlushBar = true}) async {
|
Future<bool> _testConnection({bool showFlushBar = true}) async {
|
||||||
final formData = ref.read(nodeFormDataProvider);
|
final formData = ref.read(nodeFormDataProvider);
|
||||||
|
|
||||||
|
@ -87,41 +125,19 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
case Coin.monero:
|
case Coin.monero:
|
||||||
case Coin.wownero:
|
case Coin.wownero:
|
||||||
try {
|
try {
|
||||||
final uri = Uri.parse(formData.host!);
|
final url = formData.host!;
|
||||||
if (uri.scheme.startsWith("http")) {
|
final uri = Uri.tryParse(url);
|
||||||
final String path = uri.path.isEmpty ? "/json_rpc" : uri.path;
|
if (uri != null) {
|
||||||
|
if (!uri.hasScheme) {
|
||||||
|
// try https first
|
||||||
|
testPassed = await _xmrHelper("https://$url", formData.port);
|
||||||
|
|
||||||
String uriString =
|
if (testPassed == false) {
|
||||||
"${uri.scheme}://${uri.host}:${formData.port ?? 0}$path";
|
// try http
|
||||||
|
testPassed = await _xmrHelper("http://$url", formData.port);
|
||||||
if (uri.host == "https") {
|
|
||||||
ref.read(nodeFormDataProvider).useSSL = true;
|
|
||||||
} else {
|
|
||||||
ref.read(nodeFormDataProvider).useSSL = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
final response = await testMoneroNodeConnection(
|
|
||||||
Uri.parse(uriString),
|
|
||||||
false,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.cert != null) {
|
|
||||||
if (mounted) {
|
|
||||||
final shouldAllowBadCert = await showBadX509CertificateDialog(
|
|
||||||
response.cert!,
|
|
||||||
response.url!,
|
|
||||||
response.port!,
|
|
||||||
context,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (shouldAllowBadCert) {
|
|
||||||
final response = await testMoneroNodeConnection(
|
|
||||||
Uri.parse(uriString), true);
|
|
||||||
testPassed = response.success;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
testPassed = response.success;
|
testPassed = await _xmrHelper(url, formData.port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
|
@ -167,7 +183,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showFlushBar) {
|
if (showFlushBar && mounted) {
|
||||||
if (testPassed) {
|
if (testPassed) {
|
||||||
unawaited(showFloatingFlushBar(
|
unawaited(showFloatingFlushBar(
|
||||||
type: FlushBarType.success,
|
type: FlushBarType.success,
|
||||||
|
@ -191,7 +207,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
|
||||||
|
|
||||||
bool? shouldSave;
|
bool? shouldSave;
|
||||||
|
|
||||||
if (!canConnect) {
|
if (!canConnect && mounted) {
|
||||||
await showDialog<dynamic>(
|
await showDialog<dynamic>(
|
||||||
context: context,
|
context: context,
|
||||||
useSafeArea: true,
|
useSafeArea: true,
|
||||||
|
@ -985,7 +1001,6 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
||||||
controller: _usernameController,
|
controller: _usernameController,
|
||||||
readOnly: shouldBeReadOnly,
|
readOnly: shouldBeReadOnly,
|
||||||
enabled: enableField(_usernameController),
|
enabled: enableField(_usernameController),
|
||||||
keyboardType: TextInputType.number,
|
|
||||||
focusNode: _usernameFocusNode,
|
focusNode: _usernameFocusNode,
|
||||||
style: STextStyles.field(context),
|
style: STextStyles.field(context),
|
||||||
decoration: standardInputDecoration(
|
decoration: standardInputDecoration(
|
||||||
|
@ -1034,7 +1049,7 @@ class _NodeFormState extends ConsumerState<NodeForm> {
|
||||||
controller: _passwordController,
|
controller: _passwordController,
|
||||||
readOnly: shouldBeReadOnly,
|
readOnly: shouldBeReadOnly,
|
||||||
enabled: enableField(_passwordController),
|
enabled: enableField(_passwordController),
|
||||||
keyboardType: TextInputType.number,
|
obscureText: true,
|
||||||
focusNode: _passwordFocusNode,
|
focusNode: _passwordFocusNode,
|
||||||
style: STextStyles.field(context),
|
style: STextStyles.field(context),
|
||||||
decoration: standardInputDecoration(
|
decoration: standardInputDecoration(
|
||||||
|
|
|
@ -148,15 +148,16 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
|
||||||
),
|
),
|
||||||
children: infoToggle
|
children: infoToggle
|
||||||
? [
|
? [
|
||||||
|
if (Constants.enableExchange)
|
||||||
|
const TextSpan(
|
||||||
|
text:
|
||||||
|
"Exchange data preloaded for a seamless experience.\n\n"),
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
text:
|
text:
|
||||||
"Exchange data preloaded for a seamless experience."),
|
"CoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency).\n\n"),
|
||||||
const TextSpan(
|
|
||||||
text:
|
|
||||||
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text:
|
text:
|
||||||
"\n\nRecommended for most crypto users.",
|
"Recommended for most crypto users.",
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles
|
? STextStyles
|
||||||
.desktopTextExtraExtraSmall600(
|
.desktopTextExtraExtraSmall600(
|
||||||
|
@ -170,15 +171,16 @@ class _StackPrivacyCalls extends ConsumerState<StackPrivacyCalls> {
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
: [
|
: [
|
||||||
|
if (Constants.enableExchange)
|
||||||
|
const TextSpan(
|
||||||
|
text:
|
||||||
|
"Exchange data not preloaded (slower experience).\n\n"),
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
text:
|
text:
|
||||||
"Exchange data not preloaded (slower experience)."),
|
"CoinGecko disabled (price changes not shown, no wallet value shown in other currencies).\n\n"),
|
||||||
const TextSpan(
|
|
||||||
text:
|
|
||||||
"\n\nCoinGecko disabled (price changes not shown, no wallet value shown in other currencies)."),
|
|
||||||
TextSpan(
|
TextSpan(
|
||||||
text:
|
text:
|
||||||
"\n\nRecommended for the privacy conscious.",
|
"Recommended for the privacy conscious.",
|
||||||
style: isDesktop
|
style: isDesktop
|
||||||
? STextStyles
|
? STextStyles
|
||||||
.desktopTextExtraExtraSmall600(
|
.desktopTextExtraExtraSmall600(
|
||||||
|
|
|
@ -45,6 +45,7 @@ import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart';
|
||||||
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/show_loading.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
import 'package:stackwallet/utilities/theme/stack_colors.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -261,11 +262,6 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
void _onExchangePressed(BuildContext context) async {
|
void _onExchangePressed(BuildContext context) async {
|
||||||
final coin = ref.read(managerProvider).coin;
|
final coin = ref.read(managerProvider).coin;
|
||||||
|
|
||||||
final currency = ExchangeDataLoadingService.instance.isar.currencies
|
|
||||||
.where()
|
|
||||||
.tickerEqualToAnyExchangeNameName(coin.ticker)
|
|
||||||
.findFirstSync();
|
|
||||||
|
|
||||||
if (coin.isTestNet) {
|
if (coin.isTestNet) {
|
||||||
await showDialog<void>(
|
await showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -274,6 +270,15 @@ class _WalletViewState extends ConsumerState<WalletView> {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
final currency = await showLoading(
|
||||||
|
whileFuture: ExchangeDataLoadingService.instance.isar.currencies
|
||||||
|
.where()
|
||||||
|
.tickerEqualToAnyExchangeNameName(coin.ticker)
|
||||||
|
.findFirst(),
|
||||||
|
context: context,
|
||||||
|
message: "Loading...",
|
||||||
|
);
|
||||||
|
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
unawaited(
|
unawaited(
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
|
|
|
@ -96,9 +96,10 @@ class _StackPrivacyDialog extends ConsumerState<StackPrivacyDialog> {
|
||||||
),
|
),
|
||||||
children: infoToggle
|
children: infoToggle
|
||||||
? [
|
? [
|
||||||
const TextSpan(
|
if (Constants.enableExchange)
|
||||||
text:
|
const TextSpan(
|
||||||
"Exchange data preloaded for a seamless experience."),
|
text:
|
||||||
|
"Exchange data preloaded for a seamless experience."),
|
||||||
const TextSpan(
|
const TextSpan(
|
||||||
text:
|
text:
|
||||||
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."),
|
"\n\nCoinGecko enabled: (24 hour price change shown in-app, total wallet value shown in USD or other currency)."),
|
||||||
|
|
|
@ -273,25 +273,25 @@ class ExchangeDataLoadingService {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Future<void> loadMajesticBankCurrencies() async {
|
Future<void> loadMajesticBankCurrencies() async {
|
||||||
final exchange = MajesticBankExchange.instance;
|
// final exchange = MajesticBankExchange.instance;
|
||||||
final responseCurrencies = await exchange.getAllCurrencies(false);
|
// final responseCurrencies = await exchange.getAllCurrencies(false);
|
||||||
|
//
|
||||||
if (responseCurrencies.value != null) {
|
// if (responseCurrencies.value != null) {
|
||||||
await isar.writeTxn(() async {
|
await isar.writeTxn(() async {
|
||||||
final idsToDelete = await isar.currencies
|
final idsToDelete = await isar.currencies
|
||||||
.where()
|
.where()
|
||||||
.exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
.exchangeNameEqualTo(MajesticBankExchange.exchangeName)
|
||||||
.idProperty()
|
.idProperty()
|
||||||
.findAll();
|
.findAll();
|
||||||
await isar.currencies.deleteAll(idsToDelete);
|
await isar.currencies.deleteAll(idsToDelete);
|
||||||
await isar.currencies.putAll(responseCurrencies.value!);
|
// await isar.currencies.putAll(responseCurrencies.value!);
|
||||||
});
|
});
|
||||||
} else {
|
// } else {
|
||||||
Logging.instance.log(
|
// Logging.instance.log(
|
||||||
"loadMajesticBankCurrencies: $responseCurrencies",
|
// "loadMajesticBankCurrencies: $responseCurrencies",
|
||||||
level: LogLevel.Warning,
|
// level: LogLevel.Warning,
|
||||||
);
|
// );
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// Future<void> loadMajesticBankPairs() async {
|
// Future<void> loadMajesticBankPairs() async {
|
||||||
|
|
|
@ -14,10 +14,11 @@ import 'package:stackwallet/services/exchange/exchange_response.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
|
||||||
class MajesticBankAPI {
|
class MajesticBankAPI {
|
||||||
static const String scheme = "https";
|
// ensure no api calls go out to mb
|
||||||
static const String authority = "majesticbank.sc";
|
static const String scheme = ""; //"""https";
|
||||||
static const String version = "v1";
|
static const String authority = ""; //"""majesticbank.sc";
|
||||||
static const kMajesticBankRefCode = "rjWugM";
|
static const String version = ""; //"""v1";
|
||||||
|
static const kMajesticBankRefCode = ""; //"""rjWugM";
|
||||||
|
|
||||||
MajesticBankAPI._();
|
MajesticBankAPI._();
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ class MajesticBankAPI {
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<dynamic> _makeGetRequest(Uri uri) async {
|
Future<dynamic> _makeGetRequest(Uri uri) async {
|
||||||
|
return null;
|
||||||
|
|
||||||
final client = this.client ?? http.Client();
|
final client = this.client ?? http.Client();
|
||||||
int code = -1;
|
int code = -1;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart';
|
||||||
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
import 'package:stackwallet/models/exchange/response_objects/trade.dart';
|
||||||
import 'package:stackwallet/models/notification_model.dart';
|
import 'package:stackwallet/models/notification_model.dart';
|
||||||
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
import 'package:stackwallet/services/exchange/exchange_response.dart';
|
||||||
|
import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart';
|
||||||
import 'package:stackwallet/services/node_service.dart';
|
import 'package:stackwallet/services/node_service.dart';
|
||||||
import 'package:stackwallet/services/notifications_api.dart';
|
import 'package:stackwallet/services/notifications_api.dart';
|
||||||
import 'package:stackwallet/services/trade_service.dart';
|
import 'package:stackwallet/services/trade_service.dart';
|
||||||
|
@ -197,57 +198,59 @@ class NotificationsService extends ChangeNotifier {
|
||||||
final oldTrade = trades.first;
|
final oldTrade = trades.first;
|
||||||
late final ExchangeResponse<Trade> response;
|
late final ExchangeResponse<Trade> response;
|
||||||
|
|
||||||
try {
|
if (oldTrade.exchangeName != MajesticBankExchange.exchangeName) {
|
||||||
final exchange = Exchange.fromName(oldTrade.exchangeName);
|
try {
|
||||||
response = await exchange.updateTrade(oldTrade);
|
final exchange = Exchange.fromName(oldTrade.exchangeName);
|
||||||
} catch (_) {
|
response = await exchange.updateTrade(oldTrade);
|
||||||
return;
|
} catch (_) {
|
||||||
}
|
return;
|
||||||
|
|
||||||
if (response.value == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final trade = response.value!;
|
|
||||||
|
|
||||||
// only update if status has changed
|
|
||||||
if (trade.status != notification.title) {
|
|
||||||
bool shouldWatchForUpdates = true;
|
|
||||||
// TODO: make sure we set shouldWatchForUpdates to correct value here
|
|
||||||
switch (trade.status) {
|
|
||||||
case "Refunded":
|
|
||||||
case "refunded":
|
|
||||||
case "Failed":
|
|
||||||
case "failed":
|
|
||||||
case "closed":
|
|
||||||
case "expired":
|
|
||||||
case "Finished":
|
|
||||||
case "finished":
|
|
||||||
case "Completed":
|
|
||||||
case "completed":
|
|
||||||
case "Not found":
|
|
||||||
shouldWatchForUpdates = false;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
shouldWatchForUpdates = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final updatedNotification = notification.copyWith(
|
if (response.value == null) {
|
||||||
title: trade.status,
|
return;
|
||||||
shouldWatchForUpdates: shouldWatchForUpdates,
|
|
||||||
);
|
|
||||||
|
|
||||||
// remove from watch list if shouldWatchForUpdates was changed
|
|
||||||
if (!shouldWatchForUpdates) {
|
|
||||||
await _deleteWatchedTradeNotification(notification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// replaces the current notification with the updated one
|
final trade = response.value!;
|
||||||
unawaited(add(updatedNotification, true));
|
|
||||||
|
|
||||||
// update the trade in db
|
// only update if status has changed
|
||||||
// over write trade stored in db with updated version
|
if (trade.status != notification.title) {
|
||||||
await tradesService.edit(trade: trade, shouldNotifyListeners: true);
|
bool shouldWatchForUpdates = true;
|
||||||
|
// TODO: make sure we set shouldWatchForUpdates to correct value here
|
||||||
|
switch (trade.status) {
|
||||||
|
case "Refunded":
|
||||||
|
case "refunded":
|
||||||
|
case "Failed":
|
||||||
|
case "failed":
|
||||||
|
case "closed":
|
||||||
|
case "expired":
|
||||||
|
case "Finished":
|
||||||
|
case "finished":
|
||||||
|
case "Completed":
|
||||||
|
case "completed":
|
||||||
|
case "Not found":
|
||||||
|
shouldWatchForUpdates = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
shouldWatchForUpdates = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final updatedNotification = notification.copyWith(
|
||||||
|
title: trade.status,
|
||||||
|
shouldWatchForUpdates: shouldWatchForUpdates,
|
||||||
|
);
|
||||||
|
|
||||||
|
// remove from watch list if shouldWatchForUpdates was changed
|
||||||
|
if (!shouldWatchForUpdates) {
|
||||||
|
await _deleteWatchedTradeNotification(notification);
|
||||||
|
}
|
||||||
|
|
||||||
|
// replaces the current notification with the updated one
|
||||||
|
unawaited(add(updatedNotification, true));
|
||||||
|
|
||||||
|
// update the trade in db
|
||||||
|
// over write trade stored in db with updated version
|
||||||
|
await tradesService.edit(trade: trade, shouldNotifyListeners: true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ Future<T> showLoading<T>({
|
||||||
required String message,
|
required String message,
|
||||||
String? subMessage,
|
String? subMessage,
|
||||||
bool isDesktop = false,
|
bool isDesktop = false,
|
||||||
|
bool opaqueBG = false,
|
||||||
}) async {
|
}) async {
|
||||||
unawaited(
|
unawaited(
|
||||||
showDialog<void>(
|
showDialog<void>(
|
||||||
|
@ -21,7 +22,7 @@ Future<T> showLoading<T>({
|
||||||
color: Theme.of(context)
|
color: Theme.of(context)
|
||||||
.extension<StackColors>()!
|
.extension<StackColors>()!
|
||||||
.overlay
|
.overlay
|
||||||
.withOpacity(0.6),
|
.withOpacity(opaqueBG ? 1.0 : 0.6),
|
||||||
child: CustomLoadingOverlay(
|
child: CustomLoadingOverlay(
|
||||||
message: message,
|
message: message,
|
||||||
subMessage: subMessage,
|
subMessage: subMessage,
|
||||||
|
@ -34,10 +35,9 @@ Future<T> showLoading<T>({
|
||||||
|
|
||||||
final result = await whileFuture;
|
final result = await whileFuture;
|
||||||
|
|
||||||
// TODO: update to flutter 3.7.x to take advantage of context.mounted
|
if (context.mounted) {
|
||||||
// if (mounted) {
|
Navigator.of(context, rootNavigator: isDesktop).pop();
|
||||||
Navigator.of(context, rootNavigator: isDesktop).pop();
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ description: Stack Wallet
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.6.5+147
|
version: 1.6.6+148
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.17.0 <3.0.0"
|
sdk: ">=2.17.0 <3.0.0"
|
||||||
|
|
Loading…
Reference in a new issue