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

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

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

Loading…
Cancel
Save