@@ -71,7 +71,6 @@ import {
71
71
filterLogByTopics ,
72
72
getAllReceiptsAtBlock ,
73
73
getHealthResult ,
74
- getTimestamp ,
75
74
getTransactionRequest ,
76
75
hexlifyRpcResult ,
77
76
isEvmExtrinsic ,
@@ -609,6 +608,12 @@ export abstract class BaseProvider extends AbstractProvider {
609
608
: this . bestBlockNumber
610
609
) ;
611
610
611
+ getTimestamp = async ( blockHash : string ) : Promise < number > => {
612
+ const apiAt = await this . getApiAt ( blockHash ) ;
613
+ const timestamp = await apiAt . query . timestamp . now ( ) ;
614
+ return timestamp . toNumber ( ) ;
615
+ } ;
616
+
612
617
getBlockData = async ( _blockTag : BlockTag | Promise < BlockTag > , full ?: boolean ) : Promise < BlockData > => {
613
618
const blockTag = await this . _ensureSafeModeBlockTagFinalization ( _blockTag ) ;
614
619
const header = await this . _getBlockHeader ( blockTag ) ;
@@ -629,7 +634,7 @@ export abstract class BaseProvider extends AbstractProvider {
629
634
const [ block , headerExtended , timestamp , receiptsFromSubql ] = await Promise . all ( [
630
635
this . api . rpc . chain . getBlock ( blockHash ) ,
631
636
this . api . derive . chain . getHeader ( blockHash ) ,
632
- getTimestamp ( this . api , blockHash ) ,
637
+ this . getTimestamp ( blockHash ) ,
633
638
this . subql ?. getAllReceiptsAtBlock ( blockHash ) ,
634
639
] ) ;
635
640
@@ -1408,7 +1413,7 @@ export abstract class BaseProvider extends AbstractProvider {
1408
1413
result . blockNumber = startBlock ;
1409
1414
result . blockHash = startBlockHash ;
1410
1415
1411
- const timestamp = await getTimestamp ( this . api , result . blockHash ) ;
1416
+ const timestamp = await this . getTimestamp ( result . blockHash ) ;
1412
1417
result . timestamp = Math . floor ( timestamp / 1000 ) ;
1413
1418
1414
1419
result . wait = async ( confirms ?: number , timeoutMs ?: number ) => {
0 commit comments