@@ -30,11 +30,11 @@ export function getTimeAt(_spokePool: unknown, _blockNumber: number): Promise<nu
30
30
}
31
31
32
32
/**
33
- * Retrieves the chain time at a particular block .
33
+ * Retrieves the chain time at a particular slot .
34
34
* @note This should be the same as getTimeAt() but can differ in test. These two functions should be consolidated.
35
- * @returns The chain time at the specified block tag .
35
+ * @returns The chain time at the specified slot .
36
36
*/
37
- export async function getTimestampForBlock ( provider : Provider , slotNumber : number ) : Promise < number > {
37
+ export async function getTimestampForSlot ( provider : Provider , slotNumber : number ) : Promise < number > {
38
38
const block = await provider . getBlock ( BigInt ( slotNumber ) ) . send ( ) ;
39
39
let timestamp : number ;
40
40
if ( ! block ?. blockTime ) {
@@ -67,50 +67,6 @@ export function getDepositIdAtBlock(_contract: unknown, _blockTag: number): Prom
67
67
throw new Error ( "getDepositIdAtBlock: not implemented" ) ;
68
68
}
69
69
70
- /**
71
- * xxx todo
72
- */
73
- export async function getSlotForBlock (
74
- provider : Provider ,
75
- blockNumber : bigint ,
76
- lowSlot : bigint ,
77
- _highSlot ?: bigint
78
- ) : Promise < bigint | undefined > {
79
- // @todo : Factor getBlock out to SlotFinder ??
80
- const getBlockNumber = async ( slot : bigint ) : Promise < bigint > => {
81
- const block = await provider
82
- . getBlock ( slot , { transactionDetails : "none" , maxSupportedTransactionVersion : 0 } )
83
- . send ( ) ;
84
- return block ?. blockHeight ?? BigInt ( 0 ) ; // @xxx Handle undefined here!
85
- } ;
86
-
87
- let highSlot = _highSlot ?? ( await provider . getSlot ( ) . send ( ) ) ;
88
- const [ blockLow = 0 , blockHigh = 1_000_000_000 ] = await Promise . all ( [
89
- getBlockNumber ( lowSlot ) ,
90
- getBlockNumber ( highSlot ) ,
91
- ] ) ;
92
-
93
- if ( blockLow > blockNumber || blockHigh < blockNumber ) {
94
- return undefined ; // blockNumber did not occur within the specified block range.
95
- }
96
-
97
- // Find the lowest slot number where blockHeight is greater than the requested blockNumber.
98
- do {
99
- const midSlot = ( highSlot + lowSlot ) / BigInt ( 2 ) ;
100
- const midBlock = await getBlockNumber ( midSlot ) ;
101
-
102
- if ( midBlock < blockNumber ) {
103
- lowSlot = midSlot + BigInt ( 1 ) ;
104
- } else if ( midBlock > blockNumber ) {
105
- highSlot = midSlot + BigInt ( 1 ) ; // blockNumber occurred at or earlier than midBlock.
106
- } else {
107
- return midSlot ;
108
- }
109
- } while ( lowSlot <= highSlot ) ;
110
-
111
- return undefined ;
112
- }
113
-
114
70
export function findDepositBlock (
115
71
_spokePool : unknown ,
116
72
depositId : BigNumber ,
0 commit comments