import { providers } from 'ethers' ; import { Web3Provider } from '@ethersproject/providers' ; export const timeTravel = async ( provider , time ) => { await provider . send ( 'evm_increaseTime' , [ time ] ) ; await provider . send ( 'evm_mine' , [ ] ) ; } ; export const timeTravelTo = async ( provider , timestamp ) => { await provider . send ( 'evm_mine' , [ timestamp ] ) ; } ; export const skipBlocksWithProvider = async ( provider , numberOfBlocks ) => { for ( let i = 0 ; i < numberOfBlocks ; i ++ ) { await provider . send ( 'evm_mine' , [ ] ) ; } } ; export const getBlockNumber = async ( provider ) => Number . parseInt ( await provider . send ( 'eth_blockNumber' , [ ] ) ) ; export const skipToBlockWithProvider = async ( provider , targetBlock ) => { const block = await getBlockNumber ( provider ) ; if ( block > targetBlock ) { throw new Error ( 'Already past target block' ) ; } while ( await getBlockNumber ( provider ) < targetBlock ) { await provider . send ( 'evm_mine' , [ ] ) ; } } ;