CAKE-345 | applied "any" method instead "where" and made single conditions in the createTransaction method (electrum and monero wallets); renamed credentialAmount on totalAmount and made it final in the monero_wallet.dart; made optional paymentId in createTransaction and createTransactionMultDest methods in the transaction_history.dart

wownero
OleksandrSobol 3 years ago
parent 1e3ec8da1c
commit a8375321bc

@ -205,7 +205,7 @@ PendingTransactionDescription _createTransactionMultDestSync(Map args) {
Future<PendingTransactionDescription> createTransaction( Future<PendingTransactionDescription> createTransaction(
{String address, {String address,
String paymentId, String paymentId = '',
String amount, String amount,
int priorityRaw, int priorityRaw,
int accountIndex = 0}) => int accountIndex = 0}) =>
@ -219,7 +219,7 @@ Future<PendingTransactionDescription> createTransaction(
Future<PendingTransactionDescription> createTransactionMultDest( Future<PendingTransactionDescription> createTransactionMultDest(
{List<MoneroOutput> outputs, {List<MoneroOutput> outputs,
String paymentId, String paymentId = '',
int priorityRaw, int priorityRaw,
int accountIndex = 0}) => int accountIndex = 0}) =>
compute(_createTransactionMultDestSync, { compute(_createTransactionMultDestSync, {

@ -186,16 +186,8 @@ abstract class ElectrumWalletBase extends WalletBase<ElectrumBalance,
var fee = 0; var fee = 0;
if (hasMultiDestination) { if (hasMultiDestination) {
final sendAllItems = outputs.where((item) => item.sendAll).toList(); if (outputs.any((item) => item.sendAll) ||
outputs.any((item) => item.formattedCryptoAmount <= 0)) {
if (sendAllItems?.isNotEmpty ?? false) {
throw BitcoinTransactionWrongBalanceException(currency);
}
final nullAmountItems = outputs.where((item) =>
item.formattedCryptoAmount <= 0).toList();
if (nullAmountItems?.isNotEmpty ?? false) {
throw BitcoinTransactionWrongBalanceException(currency); throw BitcoinTransactionWrongBalanceException(currency);
} }

@ -163,25 +163,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
} }
if (hasMultiDestination) { if (hasMultiDestination) {
final sendAllItems = outputs.where((item) => item.sendAll).toList(); if (outputs.any((item) => item.sendAll) ||
outputs.any((item) => item.formattedCryptoAmount <= 0)) {
if (sendAllItems?.isNotEmpty ?? false) {
throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.');
}
final nullAmountItems = outputs.where((item) =>
item.formattedCryptoAmount <= 0).toList();
if (nullAmountItems?.isNotEmpty ?? false) {
throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.');
} }
var credentialsAmount = 0; final int totalAmount = outputs.fold(0, (acc, value) =>
credentialsAmount = outputs.fold(0, (acc, value) =>
acc + value.formattedCryptoAmount); acc + value.formattedCryptoAmount);
if (unlockedBalance < credentialsAmount) { if (unlockedBalance < totalAmount) {
throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.'); throw MoneroTransactionCreationException('Wrong balance. Not enough XMR on your balance.');
} }
@ -194,7 +184,6 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
pendingTransactionDescription = pendingTransactionDescription =
await transaction_history.createTransactionMultDest( await transaction_history.createTransactionMultDest(
outputs: moneroOutputs, outputs: moneroOutputs,
paymentId: '',
priorityRaw: _credentials.priority.serialize(), priorityRaw: _credentials.priority.serialize(),
accountIndex: walletAddresses.account.id); accountIndex: walletAddresses.account.id);
} else { } else {
@ -218,7 +207,6 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
pendingTransactionDescription = pendingTransactionDescription =
await transaction_history.createTransaction( await transaction_history.createTransaction(
address: address, address: address,
paymentId: '',
amount: amount, amount: amount,
priorityRaw: _credentials.priority.serialize(), priorityRaw: _credentials.priority.serialize(),
accountIndex: walletAddresses.account.id); accountIndex: walletAddresses.account.id);

Loading…
Cancel
Save