Skip to content

Commit daf112e

Browse files
committed
hack in prevention of spark sends to trocador swaps
1 parent 24c022a commit daf112e

File tree

2 files changed

+74
-66
lines changed

2 files changed

+74
-66
lines changed

lib/app_config.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,13 @@ abstract class AppConfig {
7272
/// Fuzzy logic. Use with caution!!
7373
@Deprecated("dangerous")
7474
static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) {
75-
final name = prettyName.replaceAll(" ", "").toLowerCase();
75+
// trocador hack
76+
const hackSplitter = " (Mainnet";
77+
final name =
78+
prettyName.contains(hackSplitter)
79+
? prettyName.split(hackSplitter).first.toLowerCase()
80+
: prettyName.replaceAll(" ", "").toLowerCase();
81+
7682
try {
7783
return coins.firstWhere(
7884
(e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName,

lib/pages/exchange_view/send_from_view.dart

Lines changed: 67 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../../models/exchange/response_objects/trade.dart';
2020
import '../../pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
2121
import '../../providers/providers.dart';
2222
import '../../route_generator.dart';
23+
import '../../services/exchange/trocador/trocador_exchange.dart';
2324
import '../../themes/coin_icon_provider.dart';
2425
import '../../themes/stack_colors.dart';
2526
import '../../themes/theme_providers.dart';
@@ -406,12 +407,6 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
406407

407408
@override
408409
Widget build(BuildContext context) {
409-
final wallet = ref.watch(pWallets).getWallet(walletId);
410-
411-
final locale = ref.watch(
412-
localeServiceChangeNotifierProvider.select((value) => value.locale),
413-
);
414-
415410
final coin = ref.watch(pWalletCoin(walletId));
416411

417412
final isFiro = coin is Firo;
@@ -430,70 +425,77 @@ class _SendFromCardState extends ConsumerState<SendFromCard> {
430425
mainAxisSize: MainAxisSize.min,
431426
crossAxisAlignment: CrossAxisAlignment.start,
432427
children: [
433-
MaterialButton(
434-
splashColor:
435-
Theme.of(context).extension<StackColors>()!.highlight,
436-
key: Key("walletsSheetItemButtonFiroPrivateKey_$walletId"),
437-
padding: const EdgeInsets.all(0),
438-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
439-
shape: RoundedRectangleBorder(
440-
borderRadius: BorderRadius.circular(
441-
Constants.size.circularBorderRadius,
428+
if (!trade.exchangeName.startsWith(
429+
TrocadorExchange.exchangeName,
430+
))
431+
MaterialButton(
432+
splashColor:
433+
Theme.of(context).extension<StackColors>()!.highlight,
434+
key: Key(
435+
"walletsSheetItemButtonFiroPrivateKey_$walletId",
442436
),
443-
),
444-
onPressed: () async {
445-
if (mounted) {
446-
unawaited(_send(shouldSendPublicFiroFunds: false));
447-
}
448-
},
449-
child: Container(
450-
color: Colors.transparent,
451-
child: Padding(
452-
padding: const EdgeInsets.only(
453-
top: 6,
454-
left: 16,
455-
right: 16,
456-
bottom: 6,
437+
padding: const EdgeInsets.all(0),
438+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
439+
shape: RoundedRectangleBorder(
440+
borderRadius: BorderRadius.circular(
441+
Constants.size.circularBorderRadius,
457442
),
458-
child: Row(
459-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
460-
children: [
461-
Column(
462-
mainAxisSize: MainAxisSize.min,
463-
crossAxisAlignment: CrossAxisAlignment.start,
464-
children: [
465-
Text(
466-
"Use private balance",
467-
style: STextStyles.itemSubtitle(context),
468-
),
469-
Text(
470-
ref
471-
.watch(pAmountFormatter(coin))
472-
.format(
473-
ref
474-
.watch(
475-
pWalletBalanceTertiary(walletId),
476-
)
477-
.spendable,
478-
),
479-
style: STextStyles.itemSubtitle(context),
480-
),
481-
],
482-
),
483-
SvgPicture.asset(
484-
Assets.svg.chevronRight,
485-
height: 14,
486-
width: 7,
487-
color:
488-
Theme.of(
489-
context,
490-
).extension<StackColors>()!.infoItemLabel,
491-
),
492-
],
443+
),
444+
onPressed: () async {
445+
if (mounted) {
446+
unawaited(_send(shouldSendPublicFiroFunds: false));
447+
}
448+
},
449+
child: Container(
450+
color: Colors.transparent,
451+
child: Padding(
452+
padding: const EdgeInsets.only(
453+
top: 6,
454+
left: 16,
455+
right: 16,
456+
bottom: 6,
457+
),
458+
child: Row(
459+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
460+
children: [
461+
Column(
462+
mainAxisSize: MainAxisSize.min,
463+
crossAxisAlignment: CrossAxisAlignment.start,
464+
children: [
465+
Text(
466+
"Use private balance",
467+
style: STextStyles.itemSubtitle(context),
468+
),
469+
Text(
470+
ref
471+
.watch(pAmountFormatter(coin))
472+
.format(
473+
ref
474+
.watch(
475+
pWalletBalanceTertiary(
476+
walletId,
477+
),
478+
)
479+
.spendable,
480+
),
481+
style: STextStyles.itemSubtitle(context),
482+
),
483+
],
484+
),
485+
SvgPicture.asset(
486+
Assets.svg.chevronRight,
487+
height: 14,
488+
width: 7,
489+
color:
490+
Theme.of(
491+
context,
492+
).extension<StackColors>()!.infoItemLabel,
493+
),
494+
],
495+
),
493496
),
494497
),
495498
),
496-
),
497499
MaterialButton(
498500
splashColor:
499501
Theme.of(context).extension<StackColors>()!.highlight,

0 commit comments

Comments
 (0)