From 8e3fb600b34b8ece7e2ff43b2f59ce01919ad611 Mon Sep 17 00:00:00 2001 From: Gonzalo Date: Sun, 8 Oct 2023 11:25:06 -0300 Subject: [PATCH] fix: update forge-std (#214) * chore!: update forge-std to v1.7.1 This is a breaking change because v.1.7.0 introduced a breaking change. Details here https://github.com/foundry-rs/forge-std/pull/458 * chore: remove ad-hoc SerializeJson interface * chore: update functions mutability --- lib/forge-std | 2 +- src/_modules/Commands.sol | 2 +- src/_modules/Json.sol | 14 +++----------- src/_modules/Request.sol | 4 ++-- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/lib/forge-std b/lib/forge-std index 1d9650e9..f73c73d2 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 1d9650e951204a0ddce9ff89c32f1997984cef4d +Subproject commit f73c73d2018eb6a111f35e4dae7b4f27401e9421 diff --git a/src/_modules/Commands.sol b/src/_modules/Commands.sol index 1c887663..fd592adf 100644 --- a/src/_modules/Commands.sol +++ b/src/_modules/Commands.sol @@ -173,7 +173,7 @@ library commands { try vulcan.hevm.tryFfi(inputs) returns (VmSafe.FfiResult memory ffiResult) { CommandOutput memory output; - output.exitCode = ffiResult.exit_code; + output.exitCode = ffiResult.exitCode; output.stdout = ffiResult.stdout; output.stderr = ffiResult.stderr; output.command = Command(inputs); diff --git a/src/_modules/Json.sol b/src/_modules/Json.sol index 6a23b55a..7befe64e 100644 --- a/src/_modules/Json.sol +++ b/src/_modules/Json.sol @@ -7,12 +7,6 @@ import {LibError, Error} from "./Error.sol"; import "./Accounts.sol"; import "./Vulcan.sol"; -/// Hacky interface to use the `serializeJson` vm cheatcode -/// TODO: remove -interface SerializeJson { - function serializeJson(string memory, string memory) external returns (string memory); -} - struct JsonObject { string id; string serialized; @@ -235,11 +229,11 @@ library json { return vulcan.hevm.parseJsonBytes32Array(obj.serialized, key); } - function getKeys(JsonObject memory obj, string memory key) internal returns (string[] memory) { + function getKeys(JsonObject memory obj, string memory key) internal pure returns (string[] memory) { return vulcan.hevm.parseJsonKeys(obj.serialized, key); } - function getKeys(JsonObject memory obj) internal returns (string[] memory) { + function getKeys(JsonObject memory obj) internal pure returns (string[] memory) { return getKeys(obj, ""); } @@ -257,10 +251,8 @@ library json { return JsonError.Invalid().toJsonResult(); } - // TODO: remove hack to use the unreleased `serializeJson` Vm cheatcode - SerializeJson vm = SerializeJson(address(vulcan.hevm)); JsonObject memory jsonObj = create(); - jsonObj.serialized = vm.serializeJson(jsonObj.id, obj); + jsonObj.serialized = vulcan.hevm.serializeJson(jsonObj.id, obj); return Ok(jsonObj); } diff --git a/src/_modules/Request.sol b/src/_modules/Request.sol index 8c0948ab..3c47b291 100644 --- a/src/_modules/Request.sol +++ b/src/_modules/Request.sol @@ -265,7 +265,7 @@ library LibRequestClient { ); } - function toCommand(RequestClient memory self, Request memory req) internal returns (Command memory) { + function toCommand(RequestClient memory self, Request memory req) internal pure returns (Command memory) { string memory curlWriteOutTemplate = "\"\\n%{header_json}\\n\\n%{http_code}\" "; if (self._curlVersion.lessThan(semver.create(7, 83))) { @@ -562,7 +562,7 @@ library LibHeaders { return values.getStringArray(string.concat(".", key)); } - function getKeys(Headers self) internal returns (string[] memory) { + function getKeys(Headers self) internal pure returns (string[] memory) { (JsonObject memory values,) = decode(self); return values.getKeys(); }