Skip to content

Commit

Permalink
fix_: bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dlipicar committed Oct 23, 2024
1 parent 36866b3 commit 13e397a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
23 changes: 15 additions & 8 deletions services/wallet/routeexecution/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)

Check warning on line 177 in services/wallet/routeexecution/manager.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/routeexecution/manager.go#L177

Added line #L177 was not covered by tests
// 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)

Check warning on line 188 in services/wallet/routeexecution/manager.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/routeexecution/manager.go#L188

Added line #L188 was not covered by tests
}

var (
Expand All @@ -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

Check warning on line 202 in services/wallet/routeexecution/manager.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/routeexecution/manager.go#L201-L202

Added lines #L201 - L202 were not covered by tests
}
}(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)

Check warning on line 208 in services/wallet/routeexecution/manager.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/routeexecution/manager.go#L208

Added line #L208 was not covered by tests
}
}()
}

Expand Down
2 changes: 1 addition & 1 deletion services/wallet/routeexecution/route_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}).
Expand Down
4 changes: 0 additions & 4 deletions services/wallet/routeexecution/route_db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ func Test_PutRouteData(t *testing.T) {
})
}
}

func Test_simpleCacheAll(t *testing.T) {
t.Skip("Not implemented")
}
4 changes: 0 additions & 4 deletions services/wallet/routeexecution/route_db_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions services/wallet/transfer/transaction_manager_route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 316 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L316

Added line #L316 was not covered by tests
if err != nil {
return nil, err
return

Check warning on line 318 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L318

Added line #L318 was not covered by tests
}

desc.ApprovalTxSentHash, err = tm.transactor.SendTransactionWithSignature(common.Address(desc.ApprovalTxArgs.From), desc.ApprovalTxArgs.FromTokenID, multiTx.ID, approvalTxWithSignature)

Check warning on line 321 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L321

Added line #L321 was not covered by tests
if err != nil {
return nil, err
return

Check warning on line 323 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L323

Added line #L323 was not covered by tests
}

transactions = append(transactions, responses.NewRouterSentTransaction(desc.ApprovalTxArgs, desc.ApprovalTxSentHash, true))

Check warning on line 326 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L326

Added line #L326 was not covered by tests
Expand All @@ -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

Check warning on line 338 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L338

Added line #L338 was not covered by tests
}

desc.TxSentHash, err = tm.transactor.SendTransactionWithSignature(common.Address(desc.TxArgs.From), desc.TxArgs.FromTokenID, multiTx.ID, txWithSignature)
if err != nil {
return nil, err
return

Check warning on line 343 in services/wallet/transfer/transaction_manager_route.go

View check run for this annotation

Codecov / codecov/patch

services/wallet/transfer/transaction_manager_route.go#L343

Added line #L343 was not covered by tests
}

transactions = append(transactions, responses.NewRouterSentTransaction(desc.TxArgs, desc.TxSentHash, false))
Expand Down

0 comments on commit 13e397a

Please sign in to comment.