Skip to content

Commit

Permalink
fix: change the readme for better display in the IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
roderik committed Sep 21, 2024
1 parent c3dbcc0 commit b26eb86
Show file tree
Hide file tree
Showing 15 changed files with 295 additions and 97 deletions.
35 changes: 9 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
<p align="center">
<img src="https://github.com/settlemint/solidity-empty/blob/main/OG_Solidity.jpg" align="center" alt="logo" />
<p align="center">
✨ <a href="https://settlemint.com">https://settlemint.com</a> ✨
<br/>
Build your own blockchain usecase with ease.
</p>
</p>
<br/>
<p align="center">
<a href="https://github.com/settlemint/solidity-empty/actions?query=branch%3Amain"><img src="https://github.com/settlemint/solidity-empty/actions/workflows/solidity.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
<a href="https://fsl.software" rel="nofollow"><img src="https://img.shields.io/npm/l/@settlemint/solidity-empty" alt="License"></a>
<a href="https://www.npmjs.com/package/@settlemint/solidity-empty" rel="nofollow"><img src="https://img.shields.io/npm/dw/@settlemint/solidity-empty" alt="npm"></a>
<a href="https://github.com/settlemint/solidity-empty" rel="nofollow"><img src="https://img.shields.io/github/stars/settlemint/solidity-empty" alt="stars"></a>
</p>

<div align="center">
<a href="https://console.settlemint.com/documentation/">Documentation</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://discord.com/invite/Mt5yqFrey9">Discord</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://www.npmjs.com/package/@settlemint/solidity-empty">NPM</a>
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
<a href="https://github.com/settlemint/solidity-empty/issues">Issues</a>
<br />
</div>
![logo](https://github.com/settlemint/solidity-empty/blob/main/OG_Solidity.jpg)

[https://settlemint.com](https://settlemint.com)

Build your own blockchain usecase with ease.

[![CI status](https://github.com/settlemint/solidity-empty/actions/workflows/solidity.yml/badge.svg?event=push&branch=main)](https://github.com/settlemint/solidity-empty/actions?query=branch%3Amain) [![License](https://img.shields.io/npm/l/@settlemint/solidity-empty)](https://fsl.software) [![npm](https://img.shields.io/npm/dw/@settlemint/solidity-empty)](https://www.npmjs.com/package/@settlemint/solidity-empty) [![stars](https://img.shields.io/github/stars/settlemint/solidity-empty)](https://github.com/settlemint/solidity-empty)

[Documentation](https://console.settlemint.com/documentation/)[Discord](https://discord.com/invite/Mt5yqFrey9)[NPM](https://www.npmjs.com/package/@settlemint/solidity-empty)[Issues](https://github.com/settlemint/solidity-empty/issues)

## Get started

Expand Down
104 changes: 104 additions & 0 deletions lib/forge-std/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 Expand Up @@ -85,6 +89,106 @@ library stdJson {
return vm.parseJsonBytesArray(json, key);
}

function readUintOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256) {
return keyExists(json, key) ? readUint(json, key) : defaultValue;
}

function readUintArrayOr(string memory json, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory)
{
return keyExists(json, key) ? readUintArray(json, key) : defaultValue;
}

function readIntOr(string memory json, string memory key, int256 defaultValue) internal view returns (int256) {
return keyExists(json, key) ? readInt(json, key) : defaultValue;
}

function readIntArrayOr(string memory json, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory)
{
return keyExists(json, key) ? readIntArray(json, key) : defaultValue;
}

function readBytes32Or(string memory json, string memory key, bytes32 defaultValue)
internal
view
returns (bytes32)
{
return keyExists(json, key) ? readBytes32(json, key) : defaultValue;
}

function readBytes32ArrayOr(string memory json, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory)
{
return keyExists(json, key) ? readBytes32Array(json, key) : defaultValue;
}

function readStringOr(string memory json, string memory key, string memory defaultValue)
internal
view
returns (string memory)
{
return keyExists(json, key) ? readString(json, key) : defaultValue;
}

function readStringArrayOr(string memory json, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory)
{
return keyExists(json, key) ? readStringArray(json, key) : defaultValue;
}

function readAddressOr(string memory json, string memory key, address defaultValue)
internal
view
returns (address)
{
return keyExists(json, key) ? readAddress(json, key) : defaultValue;
}

function readAddressArrayOr(string memory json, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory)
{
return keyExists(json, key) ? readAddressArray(json, key) : defaultValue;
}

function readBoolOr(string memory json, string memory key, bool defaultValue) internal view returns (bool) {
return keyExists(json, key) ? readBool(json, key) : defaultValue;
}

function readBoolArrayOr(string memory json, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory)
{
return keyExists(json, key) ? readBoolArray(json, key) : defaultValue;
}

function readBytesOr(string memory json, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory)
{
return keyExists(json, key) ? readBytes(json, key) : defaultValue;
}

function readBytesArrayOr(string memory json, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory)
{
return keyExists(json, key) ? readBytesArray(json, key) : defaultValue;
}

function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory) {
return vm.serializeJson(jsonKey, rootObject);
}
Expand Down
104 changes: 104 additions & 0 deletions lib/forge-std/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 Expand Up @@ -85,6 +89,106 @@ library stdToml {
return vm.parseTomlBytesArray(toml, key);
}

function readUintOr(string memory toml, string memory key, uint256 defaultValue) internal view returns (uint256) {
return keyExists(toml, key) ? readUint(toml, key) : defaultValue;
}

function readUintArrayOr(string memory toml, string memory key, uint256[] memory defaultValue)
internal
view
returns (uint256[] memory)
{
return keyExists(toml, key) ? readUintArray(toml, key) : defaultValue;
}

function readIntOr(string memory toml, string memory key, int256 defaultValue) internal view returns (int256) {
return keyExists(toml, key) ? readInt(toml, key) : defaultValue;
}

function readIntArrayOr(string memory toml, string memory key, int256[] memory defaultValue)
internal
view
returns (int256[] memory)
{
return keyExists(toml, key) ? readIntArray(toml, key) : defaultValue;
}

function readBytes32Or(string memory toml, string memory key, bytes32 defaultValue)
internal
view
returns (bytes32)
{
return keyExists(toml, key) ? readBytes32(toml, key) : defaultValue;
}

function readBytes32ArrayOr(string memory toml, string memory key, bytes32[] memory defaultValue)
internal
view
returns (bytes32[] memory)
{
return keyExists(toml, key) ? readBytes32Array(toml, key) : defaultValue;
}

function readStringOr(string memory toml, string memory key, string memory defaultValue)
internal
view
returns (string memory)
{
return keyExists(toml, key) ? readString(toml, key) : defaultValue;
}

function readStringArrayOr(string memory toml, string memory key, string[] memory defaultValue)
internal
view
returns (string[] memory)
{
return keyExists(toml, key) ? readStringArray(toml, key) : defaultValue;
}

function readAddressOr(string memory toml, string memory key, address defaultValue)
internal
view
returns (address)
{
return keyExists(toml, key) ? readAddress(toml, key) : defaultValue;
}

function readAddressArrayOr(string memory toml, string memory key, address[] memory defaultValue)
internal
view
returns (address[] memory)
{
return keyExists(toml, key) ? readAddressArray(toml, key) : defaultValue;
}

function readBoolOr(string memory toml, string memory key, bool defaultValue) internal view returns (bool) {
return keyExists(toml, key) ? readBool(toml, key) : defaultValue;
}

function readBoolArrayOr(string memory toml, string memory key, bool[] memory defaultValue)
internal
view
returns (bool[] memory)
{
return keyExists(toml, key) ? readBoolArray(toml, key) : defaultValue;
}

function readBytesOr(string memory toml, string memory key, bytes memory defaultValue)
internal
view
returns (bytes memory)
{
return keyExists(toml, key) ? readBytes(toml, key) : defaultValue;
}

function readBytesArrayOr(string memory toml, string memory key, bytes[] memory defaultValue)
internal
view
returns (bytes[] memory)
{
return keyExists(toml, key) ? readBytesArray(toml, key) : defaultValue;
}

function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory) {
return vm.serializeJson(jsonKey, rootObject);
}
Expand Down
17 changes: 17 additions & 0 deletions lib/forge-std/src/Vm.sol

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/forge-std/test/StdAssertions.t.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;

import "../src/StdAssertions.sol";
import {StdAssertions} from "../src/StdAssertions.sol";
import {Vm} from "../src/Vm.sol";

interface VmInternal is Vm {
Expand Down
Loading

0 comments on commit b26eb86

Please sign in to comment.