diff --git a/transactions/pendingtxtracker.go b/transactions/pendingtxtracker.go index d5340fac2..598575b98 100644 --- a/transactions/pendingtxtracker.go +++ b/transactions/pendingtxtracker.go @@ -523,7 +523,7 @@ func (tm *PendingTxTracker) GetPendingEntry(chainID common.ChainID, hash eth.Has return trs[0], nil } -func (tm *PendingTxTracker) GetPendingTxForSuggestedNonce(chainID common.ChainID, address eth.Address, nonce uint64) (pendingTx uint64, err error) { +func (tm *PendingTxTracker) CountPendingTxsFromNonce(chainID common.ChainID, address eth.Address, nonce uint64) (pendingTx uint64, err error) { err = tm.db.QueryRow(` SELECT COUNT(nonce) @@ -603,7 +603,8 @@ func (tm *PendingTxTracker) addPending(transaction *PendingTransaction) error { } // TODO: maybe we should think of making (network_id, from_address, nonce) as primary key instead (network_id, hash) ???? - insert, err := tx.Prepare(`INSERT OR REPLACE INTO pending_transactions + var insert *sql.Stmt + insert, err = tx.Prepare(`INSERT OR REPLACE INTO pending_transactions (network_id, hash, timestamp, value, from_address, to_address, data, symbol, gas_price, gas_limit, type, additional_data, multi_transaction_id, status, auto_delete, nonce) diff --git a/transactions/transactor.go b/transactions/transactor.go index 7327d7f04..f60a5973a 100644 --- a/transactions/transactor.go +++ b/transactions/transactor.go @@ -97,7 +97,7 @@ func (t *Transactor) NextNonce(rpcClient *rpc.Client, chainID uint64, from types chainID == wallet_common.OptimismSepolia || chainID == wallet_common.OptimismGoerli { if t.pendingTracker != nil { - countOfPendingTXs, err := t.pendingTracker.GetPendingTxForSuggestedNonce(wallet_common.ChainID(chainID), common.Address(from), nonce) + countOfPendingTXs, err := t.pendingTracker.CountPendingTxsFromNonce(wallet_common.ChainID(chainID), common.Address(from), nonce) if err != nil { return 0, err } @@ -168,7 +168,7 @@ func (t *Transactor) SendRawTransaction(chainID uint64, rawTx string) error { return rpcWrapper.SendRawTransaction(ctx, rawTx) } -func createPendingTransactions(from common.Address, symbol string, chainID uint64, multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) (pTx *PendingTransaction) { +func createPendingTransaction(from common.Address, symbol string, chainID uint64, multiTransactionID wallet_common.MultiTransactionIDType, tx *gethtypes.Transaction) (pTx *PendingTransaction) { pTx = &PendingTransaction{ Hash: tx.Hash(), @@ -200,7 +200,7 @@ func (t *Transactor) sendTransaction(rpcWrapper *rpcWrapper, from common.Address if t.pendingTracker != nil { - tx := createPendingTransactions(from, symbol, rpcWrapper.chainID, multiTransactionID, tx) + tx := createPendingTransaction(from, symbol, rpcWrapper.chainID, multiTransactionID, tx) err := t.pendingTracker.StoreAndTrackPendingTx(tx) if err != nil {