Skip to content
Snippets Groups Projects
Commit 2f0604bb authored by poka's avatar poka
Browse files

can empty wallet

parent e4f64116
No related branches found
No related tags found
No related merge requests found
Pipeline #39052 failed
......@@ -917,6 +917,7 @@ class SubstrateSdk with ChangeNotifier {
Future<void> pay(
{required String fromAddress, required String destAddress, required double amount, required String password, required String transactionId}) async {
final walletOptions = Provider.of<WalletOptionsProvider>(homeContext, listen: false);
final sender = await _setSender(fromAddress);
final globalBalance = await getBalance(fromAddress);
......@@ -928,7 +929,9 @@ class SubstrateSdk with ChangeNotifier {
late String call;
late String tx2;
if (amount == -1) {
final defaultWalletBalance = walletOptions.balanceCache[fromAddress] ?? 0;
if (amount == -1 || amount == defaultWalletBalance) {
palette = 'balances';
call = 'transferAll';
txOptions = [destAddress, false];
......
......@@ -68,7 +68,7 @@ void paymentPopup(BuildContext context, String toAddress, String? username) {
final double toAddressBalance = walletOptions.balanceCache[toAddress] ?? 0;
// Prevent sending more than the balance with existential deposit
if (payAmountValue / balanceRatio > defaultWalletBalance - existentialDeposit) {
if (payAmountValue / balanceRatio > defaultWalletBalance - existentialDeposit && defaultWalletBalance != payAmountValue) {
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment