Skip to content

Commit dcb0d52

Browse files
Tudmotumds1
andauthored
feat: add vm.unixTime to VmSafe interface (#465)
* Add vm.unixTime to VmSafe interface * Change VmSafe.unixTime signature return to uint256 * chore: tweak vm layout --------- Co-authored-by: Matt Solomon <[email protected]>
1 parent f2e8d09 commit dcb0d52

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/Vm.sol

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ interface VmSafe {
146146
// Suspends execution of the main thread for `duration` milliseconds
147147
function sleep(uint256 duration) external;
148148

149-
// ======== Filesystem ========
149+
// ======== OS and Filesystem ========
150150

151151
// -------- Metadata --------
152152

@@ -165,6 +165,9 @@ interface VmSafe {
165165
// Get the path of the current project root.
166166
function projectRoot() external view returns (string memory path);
167167

168+
// Returns the time since unix epoch in milliseconds
169+
function unixTime() external returns (uint256 milliseconds);
170+
168171
// -------- Reading and writing --------
169172

170173
// Closes file for reading, resetting the offset and allowing to read it from beginning with readLine.
@@ -238,6 +241,14 @@ interface VmSafe {
238241
// `path` is relative to the project root.
239242
function writeLine(string calldata path, string calldata data) external;
240243

244+
// -------- Foreign Function Interface --------
245+
246+
// Performs a foreign function call via the terminal
247+
function ffi(string[] calldata commandInput) external returns (bytes memory result);
248+
249+
// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr
250+
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
251+
241252
// ======== Environment Variables ========
242253

243254
// Sets environment variables
@@ -317,14 +328,6 @@ interface VmSafe {
317328
// Signs data, (Wallet, digest) => (v, r, s)
318329
function sign(Wallet calldata wallet, bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s);
319330

320-
// ======== External Interactions ========
321-
322-
// Performs a foreign function call via the terminal
323-
function ffi(string[] calldata commandInput) external returns (bytes memory result);
324-
325-
// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr
326-
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);
327-
328331
// ======== Scripts ========
329332

330333
// -------- Broadcasting Transactions --------

test/Vm.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ contract VmTest is Test {
99
// inadvertently moved between Vm and VmSafe. This test must be updated each time a function is
1010
// added to or removed from Vm or VmSafe.
1111
function test_interfaceId() public {
12-
assertEq(type(VmSafe).interfaceId, bytes4(0x50ccd9ad), "VmSafe");
12+
assertEq(type(VmSafe).interfaceId, bytes4(0x329f5e71), "VmSafe");
1313
assertEq(type(Vm).interfaceId, bytes4(0x82ccbb14), "Vm");
1414
}
1515
}

0 commit comments

Comments
 (0)