Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
fix: Fixed logic conflicts with other chains
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Sep 20, 2023
1 parent 56a1bee commit 0b3a53b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:datadashwallet/common/common.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:mxc_logic/mxc_logic.dart';
import '../entity/transaction_history_model.dart';
Expand Down Expand Up @@ -71,15 +72,17 @@ class TransactionsHistoryUseCase extends ReactiveUseCase {
}

void checkForPendingTransactions(int chainId) {
final index = transactionsHistory.value
.indexWhere((element) => element.chainId == chainId);

if (index != -1) {
final chainTx = transactionsHistory.value[index];
final pendingTxList = chainTx.txList
.where((element) => element.status == TransactionStatus.pending);
for (TransactionModel pendingTx in pendingTxList) {
spyOnTransaction(pendingTx, chainId);
if (!Config.isMxcChains(chainId)) {
final index = transactionsHistory.value
.indexWhere((element) => element.chainId == chainId);

if (index != -1) {
final chainTx = transactionsHistory.value[index];
final pendingTxList = chainTx.txList
.where((element) => element.status == TransactionStatus.pending);
for (TransactionModel pendingTx in pendingTxList) {
spyOnTransaction(pendingTx, chainId);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,18 +181,20 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
amount: amount,
tokenAddress: token.address);

final tx = TransactionModel(
hash: res,
status: TransactionStatus.pending,
type: TransactionType.sent,
value: amount.getValueInUnit(EtherUnit.wei).toString(),
token: token,
timeStamp: DateTime.now());

_transactionHistoryUseCase.updateItemTx(tx, state.network!.chainId);

_transactionHistoryUseCase.spyOnTransaction(tx, state.network!.chainId);

if (!Config.isMxcChains(state.network!.chainId)) {
final tx = TransactionModel(
hash: res,
status: TransactionStatus.pending,
type: TransactionType.sent,
value: amount.getValueInUnit(EtherUnit.wei).toString(),
token: token,
timeStamp: DateTime.now());

_transactionHistoryUseCase.updateItemTx(tx, state.network!.chainId);

_transactionHistoryUseCase.spyOnTransaction(tx, state.network!.chainId);
}

return res;
} catch (e, s) {
addError(e, s);
Expand Down

0 comments on commit 0b3a53b

Please sign in to comment.