Skip to content

Commit

Permalink
Merge branch 'staging' into balance
Browse files Browse the repository at this point in the history
  • Loading branch information
sneurlax authored Sep 11, 2024
2 parents a9ff7cf + b0128c8 commit 8bafcb7
Show file tree
Hide file tree
Showing 14 changed files with 262 additions and 173 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.8.0'
ext.kotlin_version = '2.0.20'
repositories {
google()
mavenCentral()
Expand Down
2 changes: 1 addition & 1 deletion crypto_plugins/flutter_libmonero
24 changes: 12 additions & 12 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PODS:
- Flutter
- MTBBarcodeScanner
- SwiftProtobuf
- coinlib_flutter (0.3.2):
- coinlib_flutter (0.5.0):
- Flutter
- FlutterMacOS
- connectivity_plus (0.0.1):
Expand Down Expand Up @@ -83,14 +83,14 @@ PODS:
- SDWebImage/Core (5.13.2)
- share_plus (0.0.1):
- Flutter
- sqlite3 (3.46.0):
- sqlite3/common (= 3.46.0)
- sqlite3/common (3.46.0)
- sqlite3/fts5 (3.46.0):
- "sqlite3 (3.46.0+1)":
- "sqlite3/common (= 3.46.0+1)"
- "sqlite3/common (3.46.0+1)"
- "sqlite3/fts5 (3.46.0+1)":
- sqlite3/common
- sqlite3/perf-threadsafe (3.46.0):
- "sqlite3/perf-threadsafe (3.46.0+1)":
- sqlite3/common
- sqlite3/rtree (3.46.0):
- "sqlite3/rtree (3.46.0+1)":
- sqlite3/common
- sqlite3_flutter_libs (0.0.1):
- Flutter
Expand Down Expand Up @@ -207,13 +207,13 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0
coinlib_flutter: 6abec900d67762a6e7ccfd567a3cd3ae00bbee35
coinlib_flutter: 9275e8255ef67d3da33beb6e117d09ced4f46eb5
connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a
device_info_plus: 7545d84d8d1b896cb16a4ff98c19f07ec4b298ea
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
devicelocale: b22617f40038496deffba44747101255cee005b0
DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac
DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179
file_picker: ce3938a0df3cc1ef404671531facef740d03f920
file_picker: 09aa5ec1ab24135ccd7a1621c46c84134bfd6655
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_libepiccash: 36241aa7d3126f6521529985ccb3dc5eaf7bb317
flutter_libmonero: da68a616b73dd0374a8419c684fa6b6df2c44ffe
Expand All @@ -222,7 +222,7 @@ SPEC CHECKSUMS:
flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be
frostdart: 4c72b69ccac2f13ede744107db046a125acce597
integration_test: 13825b8a9334a850581300559b8839134b124670
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073
lelantus: 417f0221260013dfc052cae9cf4b741b6479edba
local_auth: 1740f55d7af0a2e2a8684ce225fe79d8931e808c
Expand All @@ -233,7 +233,7 @@ SPEC CHECKSUMS:
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866
share_plus: 599aa54e4ea31d4b4c0e9c911bcc26c55e791028
sqlite3: 154b084339ede06960a5b3c8160066adc9176b7d
sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630
sqlite3_flutter_libs: 0d611efdf6d1c9297d5ab03dab21b75aeebdae31
stack_wallet_backup: 5b8563aba5d8ffbf2ce1944331ff7294a0ec7c03
SwiftProtobuf: 6ef3f0e422ef90d6605ca20b21a94f6c1324d6b3
Expand Down
2 changes: 1 addition & 1 deletion ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
19 changes: 19 additions & 0 deletions lib/pages/buy_view/buy_form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class _BuyFormState extends ConsumerState<BuyForm> {
}
}

String _receivingAddressValidationErrorString = "";

void selectCrypto() async {
if (ref.read(simplexProvider).supportedCryptos.isEmpty) {
bool shouldPop = false;
Expand Down Expand Up @@ -1218,6 +1220,15 @@ class _BuyFormState extends ConsumerState<BuyForm> {
_address = newValue;
setState(() {
_addressToggleFlag = newValue.isNotEmpty;

// TODO [prio=low]: Validate address.
if (newValue.startsWith("bc1p")) {
// Display an error message or handle invalid address
_receivingAddressValidationErrorString =
"Taproot addresses are not allowed.";
} else {
_receivingAddressValidationErrorString = "";
}
});
},
focusNode: _receiveAddressFocusNode,
Expand Down Expand Up @@ -1430,6 +1441,14 @@ class _BuyFormState extends ConsumerState<BuyForm> {
),
),
),
SizedBox(
height: isDesktop ? 10 : 4,
),
if (_receivingAddressValidationErrorString.isNotEmpty)
Text(
_receivingAddressValidationErrorString,
style: STextStyles.errorSmall(context),
),
SizedBox(
height: isDesktop ? 20 : 12,
),
Expand Down
16 changes: 10 additions & 6 deletions lib/pages/send_view/confirm_transaction_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,11 @@ class _ConfirmTransactionViewState
SelectableText(
ref.watch(pAmountFormatter(coin)).format(
amountWithoutChange,
ethContract: ref
.watch(pCurrentTokenWallet)
?.tokenContract,
ethContract: widget.isTokenTx
? ref
.watch(pCurrentTokenWallet)!
.tokenContract
: null,
),
style: STextStyles.itemSubtitle12(context),
textAlign: TextAlign.right,
Expand Down Expand Up @@ -745,9 +747,11 @@ class _ConfirmTransactionViewState
SelectableText(
ref.watch(pAmountFormatter(coin)).format(
amountWithoutChange,
ethContract: ref
.read(pCurrentTokenWallet)
?.tokenContract,
ethContract: widget.isTokenTx
? ref
.watch(pCurrentTokenWallet)!
.tokenContract
: null,
),
style: STextStyles
.desktopTextExtraExtraSmall(
Expand Down
98 changes: 45 additions & 53 deletions lib/pages/send_view/send_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,48 @@ class _SendViewState extends ConsumerState<SendView> {
}
}

String _getSendAllTitle(bool showCoinControl, Set<UTXO> selectedUTXOs) {
if (showCoinControl && selectedUTXOs.isNotEmpty) {
return "Send all selected";
}

return "Send all ${coin.ticker}";
}

Amount _selectedUtxosAmount(Set<UTXO> utxos) => Amount(
rawValue:
utxos.map((e) => BigInt.from(e.value)).reduce((v, e) => v += e),
fractionDigits: ref.read(pWalletCoin(walletId)).fractionDigits,
);

Future<void> _sendAllTapped(bool showCoinControl) async {
final Amount amount;

if (showCoinControl && selectedUTXOs.isNotEmpty) {
amount = _selectedUtxosAmount(selectedUTXOs);
} else if (isFiro) {
switch (ref.read(publicPrivateBalanceStateProvider.state).state) {
case FiroType.public:
amount = ref.read(pWalletBalance(walletId)).spendable;
break;
case FiroType.lelantus:
amount = ref.read(pWalletBalanceSecondary(walletId)).spendable;
break;
case FiroType.spark:
amount = ref.read(pWalletBalanceTertiary(walletId)).spendable;
break;
}
} else {
amount = ref.read(pWalletBalance(walletId)).spendable;
}

cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
amount,
withUnitName: false,
);
_cryptoAmountChanged();
}

bool get isPaynymSend => widget.accountLite != null;

bool isCustomFee = false;
Expand Down Expand Up @@ -1772,59 +1814,9 @@ class _SendViewState extends ConsumerState<SendView> {
),
if (coin is! Ethereum && coin is! Tezos)
CustomTextButton(
text: "Send all ${coin.ticker}",
onTap: () async {
if (isFiro) {
final Amount amount;
switch (ref
.read(
publicPrivateBalanceStateProvider
.state,
)
.state) {
case FiroType.public:
amount = ref
.read(pWalletBalance(walletId))
.spendable;
break;
case FiroType.lelantus:
amount = ref
.read(
pWalletBalanceSecondary(
walletId,
),
)
.spendable;
break;
case FiroType.spark:
amount = ref
.read(
pWalletBalanceTertiary(
walletId,
),
)
.spendable;
break;
}

cryptoAmountController.text = ref
.read(pAmountFormatter(coin))
.format(
amount,
withUnitName: false,
);
} else {
cryptoAmountController.text = ref
.read(pAmountFormatter(coin))
.format(
ref
.read(pWalletBalance(walletId))
.spendable,
withUnitName: false,
);
}
_cryptoAmountChanged();
},
text: _getSendAllTitle(
showCoinControl, selectedUTXOs),
onTap: () => _sendAllTapped(showCoinControl),
),
],
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,8 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
focusNode: _toFocusNode,
style: STextStyles.field(context),
onChanged: (value) {
ref.read(desktopExchangeModelProvider)!.recipientAddress =
_toController.text;
widget.enableNextChanged.call(
_next(),
);
Expand Down Expand Up @@ -504,6 +506,8 @@ class _DesktopStep2State extends ConsumerState<DesktopStep2> {
focusNode: _refundFocusNode,
style: STextStyles.field(context),
onChanged: (value) {
ref.read(desktopExchangeModelProvider)!.refundAddress =
_refundController.text;
widget.enableNextChanged.call(
_next(),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'package:flutter/services.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';

import '../../../../models/isar/models/blockchain_data/utxo.dart';
import '../../../../models/isar/models/contact_entry.dart';
import '../../../../models/paynym/paynym_account_lite.dart';
import '../../../../models/send_view_auto_fill_data.dart';
Expand Down Expand Up @@ -932,30 +933,45 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
ref.read(pSendAmount.notifier).state = amount;
}

Future<void> sendAllTapped() async {
final info = ref.read(pWalletInfo(walletId));
String _getSendAllTitle(bool showCoinControl, Set<UTXO> selectedUTXOs) {
if (showCoinControl && selectedUTXOs.isNotEmpty) {
return "Send all selected";
}

return "Send all ${coin.ticker}";
}

Amount _selectedUtxosAmount(Set<UTXO> utxos) => Amount(
rawValue:
utxos.map((e) => BigInt.from(e.value)).reduce((v, e) => v += e),
fractionDigits: ref.read(pWalletCoin(walletId)).fractionDigits,
);

if (coin is Firo) {
Future<void> _sendAllTapped(bool showCoinControl) async {
final Amount amount;

if (showCoinControl && ref.read(desktopUseUTXOs).isNotEmpty) {
amount = _selectedUtxosAmount(ref.read(desktopUseUTXOs));
} else if (coin is Firo) {
switch (ref.read(publicPrivateBalanceStateProvider.state).state) {
case FiroType.public:
cryptoAmountController.text = info.cachedBalance.spendable.decimal
.toStringAsFixed(coin.fractionDigits);
amount = ref.read(pWalletBalance(walletId)).spendable;
break;
case FiroType.lelantus:
cryptoAmountController.text = info
.cachedBalanceSecondary.spendable.decimal
.toStringAsFixed(coin.fractionDigits);
amount = ref.read(pWalletBalanceSecondary(walletId)).spendable;
break;
case FiroType.spark:
cryptoAmountController.text = info
.cachedBalanceTertiary.spendable.decimal
.toStringAsFixed(coin.fractionDigits);
amount = ref.read(pWalletBalanceTertiary(walletId)).spendable;
break;
}
} else {
cryptoAmountController.text = info.cachedBalance.spendable.decimal
.toStringAsFixed(coin.fractionDigits);
amount = ref.read(pWalletBalance(walletId)).spendable;
}

cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format(
amount,
withUnitName: false,
);
}

void _showDesktopCoinControl() async {
Expand Down Expand Up @@ -1280,8 +1296,11 @@ class _DesktopSendState extends ConsumerState<DesktopSend> {
),
if (coin is! Ethereum && coin is! Tezos)
CustomTextButton(
text: "Send all ${coin.ticker}",
onTap: sendAllTapped,
text: _getSendAllTitle(
showCoinControl,
ref.watch(desktopUseUTXOs),
),
onTap: () => _sendAllTapped(showCoinControl),
),
],
),
Expand Down
Loading

0 comments on commit 8bafcb7

Please sign in to comment.