From 1e49295ed527a6d39602373fd0ce26fcd8025176 Mon Sep 17 00:00:00 2001 From: Dario Gabriel Lipicar Date: Tue, 22 Oct 2024 10:20:31 -0300 Subject: [PATCH] fix_: bugfixes --- services/wallet/routeexecution/manager.go | 23 ++++++++++++------- services/wallet/routeexecution/route_db.go | 2 +- .../wallet/routeexecution/route_db_test.go | 4 ---- .../wallet/routeexecution/route_db_types.go | 4 ---- .../transfer/transaction_manager_route.go | 8 +++---- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/services/wallet/routeexecution/manager.go b/services/wallet/routeexecution/manager.go index 208dd169467..7321bf732ba 100644 --- a/services/wallet/routeexecution/manager.go +++ b/services/wallet/routeexecution/manager.go @@ -6,6 +6,7 @@ import ( "time" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/log" "github.com/status-im/status-go/eth-node/types" @@ -173,16 +174,18 @@ func (m *Manager) SendRouterTransactionsWithSignatures(ctx context.Context, send response.SentTransactions, err = m.transactionManager.SendRouterTransactions(ctx, multiTx) if err != nil { + log.Error("Error sending router transactions", "error", err) // TODO #16556: Handle partially successful Tx sends? - return + // Don't return, store whichever transactions were successfully sent } + // don't overwrite err since we want to process it in the deferred function + var tmpErr error routerTransactions := m.transactionManager.GetRouterTransactions() - routeData := NewRouteData(&routeInputParams, m.buildInputParams, routerTransactions) - err = m.db.PutRouteData(routeData) - if err != nil { - return + tmpErr = m.db.PutRouteData(routeData) + if tmpErr != nil { + log.Error("Error storing route data", "error", tmpErr) } var ( @@ -193,13 +196,17 @@ func (m *Manager) SendRouterTransactionsWithSignatures(ctx context.Context, send chainIDs = append(chainIDs, tx.FromChain) addresses = append(addresses, common.Address(tx.FromAddress)) go func(chainId uint64, txHash common.Hash) { - err = m.transactionManager.WatchTransaction(context.Background(), chainId, txHash) - if err != nil { + tmpErr = m.transactionManager.WatchTransaction(context.Background(), chainId, txHash) + if tmpErr != nil { + log.Error("Error watching transaction", "error", tmpErr) return } }(tx.FromChain, common.Hash(tx.Hash)) } - err = m.transferController.CheckRecentHistory(chainIDs, addresses) + tmpErr = m.transferController.CheckRecentHistory(chainIDs, addresses) + if tmpErr != nil { + log.Error("Error checking recent history", "error", tmpErr) + } }() } diff --git a/services/wallet/routeexecution/route_db.go b/services/wallet/routeexecution/route_db.go index ad635a60b60..3dac1c12f7f 100644 --- a/services/wallet/routeexecution/route_db.go +++ b/services/wallet/routeexecution/route_db.go @@ -318,7 +318,7 @@ func getPaths(creator sqlite.StatementCreator, uuid string) ([]*routes.Path, err } func getPathTransactions(creator sqlite.StatementCreator, uuid string, pathIdx int) ([]*TransactionData, error) { - var txs []*TransactionData + txs := make([]*TransactionData, 0) q := sq.Select("is_approval", "chain_id", "tx_hash", "tx_args_json", "tx_json"). From("route_path_transactions"). Where(sq.Eq{"uuid": uuid, "path_idx": pathIdx}). diff --git a/services/wallet/routeexecution/route_db_test.go b/services/wallet/routeexecution/route_db_test.go index 30fb7850976..2d18dc26596 100644 --- a/services/wallet/routeexecution/route_db_test.go +++ b/services/wallet/routeexecution/route_db_test.go @@ -30,7 +30,3 @@ func Test_PutRouteData(t *testing.T) { }) } } - -func Test_simpleCacheAll(t *testing.T) { - t.Skip("Not implemented") -} diff --git a/services/wallet/routeexecution/route_db_types.go b/services/wallet/routeexecution/route_db_types.go index 2c9bb6895f9..59f5fd4044c 100644 --- a/services/wallet/routeexecution/route_db_types.go +++ b/services/wallet/routeexecution/route_db_types.go @@ -79,10 +79,6 @@ func NewRouteData(routeInputParams *requests.RouteInputParams, var pathData *PathData var ok bool - - fmt.Println(td.RouterPath.ProcessorName) - fmt.Println(pathDataPerProcessorName[td.RouterPath.ProcessorName]) - if pathData, ok = pathDataPerProcessorName[td.RouterPath.ProcessorName]; !ok { pathData = &PathData{ Path: td.RouterPath, diff --git a/services/wallet/transfer/transaction_manager_route.go b/services/wallet/transfer/transaction_manager_route.go index ddf378d1945..1b73a97894d 100644 --- a/services/wallet/transfer/transaction_manager_route.go +++ b/services/wallet/transfer/transaction_manager_route.go @@ -315,12 +315,12 @@ func (tm *TransactionManager) SendRouterTransactions(ctx context.Context, multiT var approvalTxWithSignature *ethTypes.Transaction approvalTxWithSignature, err = tm.transactor.AddSignatureToTransaction(desc.ApprovalTxArgs.FromChainID, desc.ApprovalTx, desc.ApprovalSignature) if err != nil { - return nil, err + return } desc.ApprovalTxSentHash, err = tm.transactor.SendTransactionWithSignature(common.Address(desc.ApprovalTxArgs.From), desc.ApprovalTxArgs.FromTokenID, multiTx.ID, approvalTxWithSignature) if err != nil { - return nil, err + return } transactions = append(transactions, responses.NewRouterSentTransaction(desc.ApprovalTxArgs, desc.ApprovalTxSentHash, true)) @@ -335,12 +335,12 @@ func (tm *TransactionManager) SendRouterTransactions(ctx context.Context, multiT var txWithSignature *ethTypes.Transaction txWithSignature, err = tm.transactor.AddSignatureToTransaction(desc.TxArgs.FromChainID, desc.Tx, desc.TxSignature) if err != nil { - return nil, err + return } desc.TxSentHash, err = tm.transactor.SendTransactionWithSignature(common.Address(desc.TxArgs.From), desc.TxArgs.FromTokenID, multiTx.ID, txWithSignature) if err != nil { - return nil, err + return } transactions = append(transactions, responses.NewRouterSentTransaction(desc.TxArgs, desc.TxSentHash, false))