@@ -21,7 +21,6 @@ export const updateMinedTx = async () => {
2121 await prisma . $transaction (
2222 async ( pgtx ) => {
2323 const txs = await getSentTxs ( { pgtx } ) ;
24-
2524 if ( txs . length === 0 ) {
2625 return ;
2726 }
@@ -32,13 +31,12 @@ export const updateMinedTx = async () => {
3231 await Promise . all (
3332 txs . map ( async ( tx ) => {
3433 const sdk = await getSdk ( { chainId : parseInt ( tx . chainId ! ) } ) ;
35- const receipt : ethers . providers . TransactionReceipt | undefined =
36- await sdk
37- . getProvider ( )
38- . getTransactionReceipt ( tx . transactionHash ! ) ;
3934 const provider =
4035 sdk . getProvider ( ) as ethers . providers . JsonRpcProvider ;
4136
37+ const receipt : ethers . providers . TransactionReceipt | undefined =
38+ await provider . getTransactionReceipt ( tx . transactionHash ! ) ;
39+
4240 if ( ! receipt ) {
4341 // This tx is not yet mined or was dropped.
4442
@@ -52,21 +50,26 @@ export const updateMinedTx = async () => {
5250 return ;
5351 }
5452
55- const response = ( await sdk
56- . getProvider ( )
57- . getTransaction (
58- tx . transactionHash ! ,
59- ) ) as ethers . providers . TransactionResponse | null ;
60-
61- // Get the timestamp when the transaction was mined
62- const minedAt = new Date (
63- (
64- await getBlock ( {
65- block : receipt . blockNumber ,
66- network : sdk . getProvider ( ) ,
67- } )
68- ) . timestamp * 1000 ,
69- ) ;
53+ const response = ( await provider . getTransaction (
54+ tx . transactionHash ! ,
55+ ) ) as ethers . providers . TransactionResponse | null ;
56+
57+ // Get the timestamp when the transaction was mined. Fall back to curent time.
58+ const block = await getBlock ( {
59+ block : receipt . blockNumber ,
60+ network : provider ,
61+ } ) ;
62+ if ( ! block ) {
63+ logger ( {
64+ service : "worker" ,
65+ level : "warn" ,
66+ queueId : tx . id ,
67+ message : `Block not found (provider=${ provider . connection . url } ).` ,
68+ } ) ;
69+ }
70+ const minedAt = block
71+ ? new Date ( block . timestamp * 1000 )
72+ : new Date ( ) ;
7073
7174 return {
7275 tx,
0 commit comments