Skip to content

Commit

Permalink
feat: add vm.unixTime to VmSafe interface (#465)
Browse files Browse the repository at this point in the history
* Add vm.unixTime to VmSafe interface

* Change VmSafe.unixTime signature return to uint256

* chore: tweak vm layout

---------

Co-authored-by: Matt Solomon <[email protected]>
  • Loading branch information
Tudmotu and mds1 authored Oct 2, 2023
1 parent f2e8d09 commit dcb0d52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions src/Vm.sol
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ interface VmSafe {
// Suspends execution of the main thread for `duration` milliseconds
function sleep(uint256 duration) external;

// ======== Filesystem ========
// ======== OS and Filesystem ========

// -------- Metadata --------

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

// Returns the time since unix epoch in milliseconds
function unixTime() external returns (uint256 milliseconds);

// -------- Reading and writing --------

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

// -------- Foreign Function Interface --------

// Performs a foreign function call via the terminal
function ffi(string[] calldata commandInput) external returns (bytes memory result);

// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);

// ======== Environment Variables ========

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

// ======== External Interactions ========

// Performs a foreign function call via the terminal
function ffi(string[] calldata commandInput) external returns (bytes memory result);

// Performs a foreign function call via terminal and returns the exit code, stdout, and stderr
function tryFfi(string[] calldata commandInput) external returns (FfiResult memory result);

// ======== Scripts ========

// -------- Broadcasting Transactions --------
Expand Down
2 changes: 1 addition & 1 deletion test/Vm.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ contract VmTest is Test {
// inadvertently moved between Vm and VmSafe. This test must be updated each time a function is
// added to or removed from Vm or VmSafe.
function test_interfaceId() public {
assertEq(type(VmSafe).interfaceId, bytes4(0x50ccd9ad), "VmSafe");
assertEq(type(VmSafe).interfaceId, bytes4(0x329f5e71), "VmSafe");
assertEq(type(Vm).interfaceId, bytes4(0x82ccbb14), "Vm");
}
}

0 comments on commit dcb0d52

Please sign in to comment.