From e41d4e9cf9d3c306ca1ef4749287b1e316e5af2b Mon Sep 17 00:00:00 2001 From: Crisgarner Date: Sat, 21 Aug 2021 15:10:13 -0600 Subject: [PATCH 1/4] Create hevm.sol --- src/hevm.sol | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/hevm.sol diff --git a/src/hevm.sol b/src/hevm.sol new file mode 100644 index 0000000..6aa6b54 --- /dev/null +++ b/src/hevm.sol @@ -0,0 +1,43 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +pragma solidity >=0.4.23; + +abstract contract Hevm { + function warp(uint256 x) external virtual; + + function roll(uint256 x) external virtual; + + function store( + address c, + bytes32 loc, + bytes32 val + ) external virtual; + + function load(address c, bytes32 loc) external virtual returns (bytes32 val); + + function sign(uint256 sk, bytes32 digest) + external + virtual + returns ( + uint8 v, + bytes32 r, + bytes32 s + ); + + function addr(uint256 sk) external virtual returns (address addr); + + function ffi(string[] calldata) external virtual returns (bytes memory); +} From cd7a7a1a74bb0fa919da8c9e055a2524a715c191 Mon Sep 17 00:00:00 2001 From: Crisgarner Date: Mon, 23 Aug 2021 18:17:46 -0600 Subject: [PATCH 2/4] Update test.sol Added hevm variable --- src/test.sol | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test.sol b/src/test.sol index 96d3c15..e296f6d 100644 --- a/src/test.sol +++ b/src/test.sol @@ -15,6 +15,8 @@ pragma solidity >=0.4.23; +import "./hevm.sol"; + contract DSTest { event log (string); event logs (bytes); @@ -40,6 +42,8 @@ contract DSTest { address constant HEVM_ADDRESS = address(bytes20(uint160(uint256(keccak256('hevm cheat code'))))); + + Hevm public hevm = Hevm(HEVM_ADDRESS); modifier mayRevert() { _; } modifier testopts(string memory) { _; } From 330b4f1f49dff076cc9ce932eb364df5eed0fe3c Mon Sep 17 00:00:00 2001 From: Crisgarner Date: Mon, 23 Aug 2021 18:26:47 -0600 Subject: [PATCH 3/4] Reformat Hevm.sol --- src/hevm.sol | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/src/hevm.sol b/src/hevm.sol index 6aa6b54..a840a47 100644 --- a/src/hevm.sol +++ b/src/hevm.sol @@ -17,27 +17,10 @@ pragma solidity >=0.4.23; abstract contract Hevm { function warp(uint256 x) external virtual; - function roll(uint256 x) external virtual; - - function store( - address c, - bytes32 loc, - bytes32 val - ) external virtual; - - function load(address c, bytes32 loc) external virtual returns (bytes32 val); - - function sign(uint256 sk, bytes32 digest) - external - virtual - returns ( - uint8 v, - bytes32 r, - bytes32 s - ); - + function store(address c,bytes32 loc,bytes32 val) external virtual; + function load(address c,bytes32 loc) external virtual returns (bytes32 val); + function sign(uint256 sk,bytes32 digest) external virtual returns (uint8 v, bytes32 r, bytes32 s); function addr(uint256 sk) external virtual returns (address addr); - function ffi(string[] calldata) external virtual returns (bytes memory); } From fc108509eba838e0b9e52868cef9322047c21c50 Mon Sep 17 00:00:00 2001 From: Crisgarner Date: Tue, 24 Aug 2021 10:42:30 -0600 Subject: [PATCH 4/4] changed to interface --- src/hevm.sol | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/hevm.sol b/src/hevm.sol index a840a47..ab978ba 100644 --- a/src/hevm.sol +++ b/src/hevm.sol @@ -15,12 +15,12 @@ pragma solidity >=0.4.23; -abstract contract Hevm { - function warp(uint256 x) external virtual; - function roll(uint256 x) external virtual; - function store(address c,bytes32 loc,bytes32 val) external virtual; - function load(address c,bytes32 loc) external virtual returns (bytes32 val); - function sign(uint256 sk,bytes32 digest) external virtual returns (uint8 v, bytes32 r, bytes32 s); - function addr(uint256 sk) external virtual returns (address addr); - function ffi(string[] calldata) external virtual returns (bytes memory); +interface Hevm { + function warp(uint256 x) external; + function roll(uint256 x) external; + function store(address c,bytes32 loc,bytes32 val) external; + function load(address c,bytes32 loc) external returns (bytes32 val); + function sign(uint256 sk,bytes32 digest) external returns (uint8 v, bytes32 r, bytes32 s); + function addr(uint256 sk) external returns (address addr); + function ffi(string[] calldata) external returns (bytes memory); }