Skip to content

Commit

Permalink
feat: add keyExists to stdJson and stdToml
Browse files Browse the repository at this point in the history
  • Loading branch information
mds1 committed Sep 18, 2024
1 parent beb836e commit 05dfd15
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/StdJson.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import {VmSafe} from "./Vm.sol";
library stdJson {
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));

function keyExists(string memory json, string memory key) internal view returns (bool) {
return vm.keyExistsJson(json, key);
}

function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {
return vm.parseJson(json, key);
}
Expand Down
4 changes: 4 additions & 0 deletions src/StdToml.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ import {VmSafe} from "./Vm.sol";
library stdToml {
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));

function keyExists(string memory toml, string memory key) internal view returns (bool) {
return vm.keyExistsToml(toml, key);
}

function parseRaw(string memory toml, string memory key) internal pure returns (bytes memory) {
return vm.parseToml(toml, key);
}
Expand Down

0 comments on commit 05dfd15

Please sign in to comment.