@@ -21,7 +21,6 @@ export const updateMinedTx = async () => {
21
21
await prisma . $transaction (
22
22
async ( pgtx ) => {
23
23
const txs = await getSentTxs ( { pgtx } ) ;
24
-
25
24
if ( txs . length === 0 ) {
26
25
return ;
27
26
}
@@ -32,13 +31,12 @@ export const updateMinedTx = async () => {
32
31
await Promise . all (
33
32
txs . map ( async ( tx ) => {
34
33
const sdk = await getSdk ( { chainId : parseInt ( tx . chainId ! ) } ) ;
35
- const receipt : ethers . providers . TransactionReceipt | undefined =
36
- await sdk
37
- . getProvider ( )
38
- . getTransactionReceipt ( tx . transactionHash ! ) ;
39
34
const provider =
40
35
sdk . getProvider ( ) as ethers . providers . JsonRpcProvider ;
41
36
37
+ const receipt : ethers . providers . TransactionReceipt | undefined =
38
+ await provider . getTransactionReceipt ( tx . transactionHash ! ) ;
39
+
42
40
if ( ! receipt ) {
43
41
// This tx is not yet mined or was dropped.
44
42
@@ -52,21 +50,26 @@ export const updateMinedTx = async () => {
52
50
return ;
53
51
}
54
52
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 ( ) ;
70
73
71
74
return {
72
75
tx,
0 commit comments