2022-03-17 13:15:04 +00:00
|
|
|
import pkg/ethers
|
2024-10-30 10:40:17 +00:00
|
|
|
import pkg/serde/json
|
2022-03-17 13:15:04 +00:00
|
|
|
|
|
|
|
proc currentTime*(provider: Provider): Future[UInt256] {.async.} =
|
2024-03-11 16:57:20 +00:00
|
|
|
return (!await provider.getBlock(BlockTag.pending)).timestamp
|
2022-03-17 13:15:04 +00:00
|
|
|
|
|
|
|
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")
|