2022-03-17 13:15:04 +00:00
|
|
|
import pkg/ethers
|
|
|
|
|
|
|
|
proc currentTime*(provider: Provider): Future[UInt256] {.async.} =
|
|
|
|
return (!await provider.getBlock(BlockTag.latest)).timestamp
|
|
|
|
|
|
|
|
proc advanceTime*(provider: JsonRpcProvider, seconds: UInt256) {.async.} =
|
2023-06-21 05:46:18 +00:00
|
|
|
discard await provider.send("evm_increaseTime", @[%("0x" & seconds.toHex)])
|
2022-03-17 13:15:04 +00:00
|
|
|
discard await provider.send("evm_mine")
|
|
|
|
|
|
|
|
proc advanceTimeTo*(provider: JsonRpcProvider, timestamp: UInt256) {.async.} =
|
|
|
|
if (await provider.currentTime()) != timestamp:
|
2023-06-21 05:46:18 +00:00
|
|
|
discard await provider.send("evm_setNextBlockTimestamp", @[%("0x" & timestamp.toHex)])
|
2022-03-17 13:15:04 +00:00
|
|
|
discard await provider.send("evm_mine")
|