@@ -8,8 +8,8 @@ use crate::{
88 utils:: option_if,
99 } ,
1010 transaction:: types:: {
11- Transaction , TransactionData , TransactionHash , TransactionId , TransactionStatus ,
12- TransactionValue ,
11+ Transaction , TransactionData , TransactionHash , TransactionId , TransactionNonce ,
12+ TransactionStatus , TransactionValue ,
1313 } ,
1414} ;
1515use alloy:: network:: AnyTransactionReceipt ;
@@ -427,6 +427,47 @@ impl PostgresClient {
427427 Ok ( ( ) )
428428 }
429429
430+ pub async fn transaction_update_nonce (
431+ & mut self ,
432+ transaction_id : & TransactionId ,
433+ nonce : & TransactionNonce ,
434+ ) -> Result < ( ) , PostgresError > {
435+ let mut conn = self . pool . get ( ) . await ?;
436+ let trans = conn. transaction ( ) . await . map_err ( PostgresError :: PgError ) ?;
437+
438+ trans
439+ . execute (
440+ "UPDATE relayer.transaction SET nonce = $2 WHERE id = $1" ,
441+ & [ & transaction_id, & ( nonce. into_inner ( ) as i64 ) ] ,
442+ )
443+ . await ?;
444+
445+ trans
446+ . execute (
447+ "
448+ INSERT INTO relayer.transaction_audit_log (
449+ id, relayer_id, \" to\" , \" from\" , nonce, chain_id, data, value, blobs, gas_limit,
450+ speed, status, expires_at, queued_at, sent_at, mined_at, confirmed_at,
451+ failed_at, failed_reason, hash, sent_max_priority_fee_per_gas,
452+ sent_max_fee_per_gas, gas_price, block_hash, block_number, external_id
453+ )
454+ SELECT
455+ id, relayer_id, \" to\" , \" from\" , $2, chain_id, data, value, blobs, gas_limit,
456+ speed, status, expires_at, queued_at, sent_at, mined_at, confirmed_at,
457+ failed_at, failed_reason, hash, sent_max_priority_fee_per_gas,
458+ sent_max_fee_per_gas, gas_price, block_hash, block_number, external_id
459+ FROM relayer.transaction
460+ WHERE id = $1;
461+ " ,
462+ & [ & transaction_id, & ( nonce. into_inner ( ) as i64 ) ] ,
463+ )
464+ . await ?;
465+
466+ trans. commit ( ) . await ?;
467+
468+ Ok ( ( ) )
469+ }
470+
430471 pub async fn transaction_expired (
431472 & mut self ,
432473 transaction_id : & TransactionId ,
0 commit comments