Skip to content

Commit

Permalink
fix!: update forge-std (#214)
Browse files Browse the repository at this point in the history
* chore!: update forge-std to v1.7.1

This is a breaking change because v.1.7.0 introduced a breaking change.

Details here foundry-rs/forge-std#458

* chore: remove ad-hoc SerializeJson interface

* chore: update functions mutability
  • Loading branch information
gnkz committed Oct 8, 2023
1 parent c411731 commit c8d907b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 4 files
+1 −1 package.json
+4 −0 src/StdJson.sol
+452 −286 src/Vm.sol
+15 −0 test/Vm.t.sol
2 changes: 1 addition & 1 deletion src/_modules/Commands.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 3 additions & 11 deletions src/_modules/Json.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, "");
}

Expand All @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/_modules/Request.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit c8d907b

Please sign in to comment.