Skip to content

Commit b26eb86

Browse files
committed
fix: change the readme for better display in the IDE
1 parent c3dbcc0 commit b26eb86

15 files changed

+295
-97
lines changed

README.md

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,12 @@
1-
<p align="center">
2-
<img src="https://github.com/settlemint/solidity-empty/blob/main/OG_Solidity.jpg" align="center" alt="logo" />
3-
<p align="center">
4-
✨ <a href="https://settlemint.com">https://settlemint.com</a> ✨
5-
<br/>
6-
Build your own blockchain usecase with ease.
7-
</p>
8-
</p>
9-
<br/>
10-
<p align="center">
11-
<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>
12-
<a href="https://fsl.software" rel="nofollow"><img src="https://img.shields.io/npm/l/@settlemint/solidity-empty" alt="License"></a>
13-
<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>
14-
<a href="https://github.com/settlemint/solidity-empty" rel="nofollow"><img src="https://img.shields.io/github/stars/settlemint/solidity-empty" alt="stars"></a>
15-
</p>
16-
17-
<div align="center">
18-
<a href="https://console.settlemint.com/documentation/">Documentation</a>
19-
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
20-
<a href="https://discord.com/invite/Mt5yqFrey9">Discord</a>
21-
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
22-
<a href="https://www.npmjs.com/package/@settlemint/solidity-empty">NPM</a>
23-
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
24-
<a href="https://github.com/settlemint/solidity-empty/issues">Issues</a>
25-
<br />
26-
</div>
1+
![logo](https://github.com/settlemint/solidity-empty/blob/main/OG_Solidity.jpg)
2+
3+
[https://settlemint.com](https://settlemint.com)
4+
5+
Build your own blockchain usecase with ease.
6+
7+
[![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)
8+
9+
[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)
2710

2811
## Get started
2912

lib/forge-std/src/StdJson.sol

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {VmSafe} from "./Vm.sol";
2525
library stdJson {
2626
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
2727

28+
function keyExists(string memory json, string memory key) internal view returns (bool) {
29+
return vm.keyExistsJson(json, key);
30+
}
31+
2832
function parseRaw(string memory json, string memory key) internal pure returns (bytes memory) {
2933
return vm.parseJson(json, key);
3034
}
@@ -85,6 +89,106 @@ library stdJson {
8589
return vm.parseJsonBytesArray(json, key);
8690
}
8791

92+
function readUintOr(string memory json, string memory key, uint256 defaultValue) internal view returns (uint256) {
93+
return keyExists(json, key) ? readUint(json, key) : defaultValue;
94+
}
95+
96+
function readUintArrayOr(string memory json, string memory key, uint256[] memory defaultValue)
97+
internal
98+
view
99+
returns (uint256[] memory)
100+
{
101+
return keyExists(json, key) ? readUintArray(json, key) : defaultValue;
102+
}
103+
104+
function readIntOr(string memory json, string memory key, int256 defaultValue) internal view returns (int256) {
105+
return keyExists(json, key) ? readInt(json, key) : defaultValue;
106+
}
107+
108+
function readIntArrayOr(string memory json, string memory key, int256[] memory defaultValue)
109+
internal
110+
view
111+
returns (int256[] memory)
112+
{
113+
return keyExists(json, key) ? readIntArray(json, key) : defaultValue;
114+
}
115+
116+
function readBytes32Or(string memory json, string memory key, bytes32 defaultValue)
117+
internal
118+
view
119+
returns (bytes32)
120+
{
121+
return keyExists(json, key) ? readBytes32(json, key) : defaultValue;
122+
}
123+
124+
function readBytes32ArrayOr(string memory json, string memory key, bytes32[] memory defaultValue)
125+
internal
126+
view
127+
returns (bytes32[] memory)
128+
{
129+
return keyExists(json, key) ? readBytes32Array(json, key) : defaultValue;
130+
}
131+
132+
function readStringOr(string memory json, string memory key, string memory defaultValue)
133+
internal
134+
view
135+
returns (string memory)
136+
{
137+
return keyExists(json, key) ? readString(json, key) : defaultValue;
138+
}
139+
140+
function readStringArrayOr(string memory json, string memory key, string[] memory defaultValue)
141+
internal
142+
view
143+
returns (string[] memory)
144+
{
145+
return keyExists(json, key) ? readStringArray(json, key) : defaultValue;
146+
}
147+
148+
function readAddressOr(string memory json, string memory key, address defaultValue)
149+
internal
150+
view
151+
returns (address)
152+
{
153+
return keyExists(json, key) ? readAddress(json, key) : defaultValue;
154+
}
155+
156+
function readAddressArrayOr(string memory json, string memory key, address[] memory defaultValue)
157+
internal
158+
view
159+
returns (address[] memory)
160+
{
161+
return keyExists(json, key) ? readAddressArray(json, key) : defaultValue;
162+
}
163+
164+
function readBoolOr(string memory json, string memory key, bool defaultValue) internal view returns (bool) {
165+
return keyExists(json, key) ? readBool(json, key) : defaultValue;
166+
}
167+
168+
function readBoolArrayOr(string memory json, string memory key, bool[] memory defaultValue)
169+
internal
170+
view
171+
returns (bool[] memory)
172+
{
173+
return keyExists(json, key) ? readBoolArray(json, key) : defaultValue;
174+
}
175+
176+
function readBytesOr(string memory json, string memory key, bytes memory defaultValue)
177+
internal
178+
view
179+
returns (bytes memory)
180+
{
181+
return keyExists(json, key) ? readBytes(json, key) : defaultValue;
182+
}
183+
184+
function readBytesArrayOr(string memory json, string memory key, bytes[] memory defaultValue)
185+
internal
186+
view
187+
returns (bytes[] memory)
188+
{
189+
return keyExists(json, key) ? readBytesArray(json, key) : defaultValue;
190+
}
191+
88192
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory) {
89193
return vm.serializeJson(jsonKey, rootObject);
90194
}

lib/forge-std/src/StdToml.sol

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import {VmSafe} from "./Vm.sol";
2525
library stdToml {
2626
VmSafe private constant vm = VmSafe(address(uint160(uint256(keccak256("hevm cheat code")))));
2727

28+
function keyExists(string memory toml, string memory key) internal view returns (bool) {
29+
return vm.keyExistsToml(toml, key);
30+
}
31+
2832
function parseRaw(string memory toml, string memory key) internal pure returns (bytes memory) {
2933
return vm.parseToml(toml, key);
3034
}
@@ -85,6 +89,106 @@ library stdToml {
8589
return vm.parseTomlBytesArray(toml, key);
8690
}
8791

92+
function readUintOr(string memory toml, string memory key, uint256 defaultValue) internal view returns (uint256) {
93+
return keyExists(toml, key) ? readUint(toml, key) : defaultValue;
94+
}
95+
96+
function readUintArrayOr(string memory toml, string memory key, uint256[] memory defaultValue)
97+
internal
98+
view
99+
returns (uint256[] memory)
100+
{
101+
return keyExists(toml, key) ? readUintArray(toml, key) : defaultValue;
102+
}
103+
104+
function readIntOr(string memory toml, string memory key, int256 defaultValue) internal view returns (int256) {
105+
return keyExists(toml, key) ? readInt(toml, key) : defaultValue;
106+
}
107+
108+
function readIntArrayOr(string memory toml, string memory key, int256[] memory defaultValue)
109+
internal
110+
view
111+
returns (int256[] memory)
112+
{
113+
return keyExists(toml, key) ? readIntArray(toml, key) : defaultValue;
114+
}
115+
116+
function readBytes32Or(string memory toml, string memory key, bytes32 defaultValue)
117+
internal
118+
view
119+
returns (bytes32)
120+
{
121+
return keyExists(toml, key) ? readBytes32(toml, key) : defaultValue;
122+
}
123+
124+
function readBytes32ArrayOr(string memory toml, string memory key, bytes32[] memory defaultValue)
125+
internal
126+
view
127+
returns (bytes32[] memory)
128+
{
129+
return keyExists(toml, key) ? readBytes32Array(toml, key) : defaultValue;
130+
}
131+
132+
function readStringOr(string memory toml, string memory key, string memory defaultValue)
133+
internal
134+
view
135+
returns (string memory)
136+
{
137+
return keyExists(toml, key) ? readString(toml, key) : defaultValue;
138+
}
139+
140+
function readStringArrayOr(string memory toml, string memory key, string[] memory defaultValue)
141+
internal
142+
view
143+
returns (string[] memory)
144+
{
145+
return keyExists(toml, key) ? readStringArray(toml, key) : defaultValue;
146+
}
147+
148+
function readAddressOr(string memory toml, string memory key, address defaultValue)
149+
internal
150+
view
151+
returns (address)
152+
{
153+
return keyExists(toml, key) ? readAddress(toml, key) : defaultValue;
154+
}
155+
156+
function readAddressArrayOr(string memory toml, string memory key, address[] memory defaultValue)
157+
internal
158+
view
159+
returns (address[] memory)
160+
{
161+
return keyExists(toml, key) ? readAddressArray(toml, key) : defaultValue;
162+
}
163+
164+
function readBoolOr(string memory toml, string memory key, bool defaultValue) internal view returns (bool) {
165+
return keyExists(toml, key) ? readBool(toml, key) : defaultValue;
166+
}
167+
168+
function readBoolArrayOr(string memory toml, string memory key, bool[] memory defaultValue)
169+
internal
170+
view
171+
returns (bool[] memory)
172+
{
173+
return keyExists(toml, key) ? readBoolArray(toml, key) : defaultValue;
174+
}
175+
176+
function readBytesOr(string memory toml, string memory key, bytes memory defaultValue)
177+
internal
178+
view
179+
returns (bytes memory)
180+
{
181+
return keyExists(toml, key) ? readBytes(toml, key) : defaultValue;
182+
}
183+
184+
function readBytesArrayOr(string memory toml, string memory key, bytes[] memory defaultValue)
185+
internal
186+
view
187+
returns (bytes[] memory)
188+
{
189+
return keyExists(toml, key) ? readBytesArray(toml, key) : defaultValue;
190+
}
191+
88192
function serialize(string memory jsonKey, string memory rootObject) internal returns (string memory) {
89193
return vm.serializeJson(jsonKey, rootObject);
90194
}

lib/forge-std/src/Vm.sol

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/forge-std/test/StdAssertions.t.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: MIT
22
pragma solidity >=0.7.0 <0.9.0;
33

4-
import "../src/StdAssertions.sol";
4+
import {StdAssertions} from "../src/StdAssertions.sol";
55
import {Vm} from "../src/Vm.sol";
66

77
interface VmInternal is Vm {

0 commit comments

Comments
 (0)