-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ππαΆ» π π°αΆ»
- Loading branch information
Showing
24 changed files
with
663 additions
and
1,097 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +0,0 @@ | ||
[submodule "lib/forge-std"] | ||
path = lib/forge-std | ||
url = https://github.com/foundry-rs/forge-std | ||
[submodule "lib/solbase"] | ||
path = lib/solbase | ||
url = https://github.com/Sol-DAO/solbase | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,45 @@ | ||
# Zolidity | ||
Zero-fuss smart contracts. | ||
# [zolidity](https://github.com/z0r0z/zolidity) [](https://opensource.org/license/mit) [](https://docs.soliditylang.org/en/v0.8.28/) [](https://getfoundry.sh/)  | ||
|
||
Experiments on Ethereum. | ||
`Zolidity`: Zero-to-One Solidity with Simplicity-first. | ||
|
||
## Getting Started | ||
|
||
Run: `curl -L https://foundry.paradigm.xyz | bash && source ~/.bashrc && foundryup` | ||
|
||
Build the foundry project with `forge build`. Run tests with `forge test`. Measure gas with `forge snapshot`. Format with `forge fmt`. | ||
|
||
## GitHub Actions | ||
|
||
Contracts will be tested and gas measured on every push and pull request. | ||
|
||
You can edit the CI script in [.github/workflows/ci.yml](./.github/workflows/ci.yml). | ||
|
||
## Blueprint | ||
|
||
```txt | ||
lib | ||
ββ forge-std β https://github.com/foundry-rs/forge-std | ||
ββ solady β https://github.com/vectorized/solady | ||
src | ||
ββ ERC20 β Standard fungible token. | ||
ββ ERC173 β Standard contract ownership. | ||
ββ ReentrancyGuard β Reentrant call guard. | ||
test | ||
ββ ERC20.t - Test standard fungible token. | ||
ββ ERC173.t β Test standard contract ownership. | ||
ββ ReentrancyGuard.t β Test reentrant call guard. | ||
``` | ||
|
||
## Inspiration | ||
|
||
- [solady](https://github.com/Vectorized/solady) | ||
- [solmate](https://github.com/transmissions11/solmate) | ||
- [snekmate](https://github.com/pcaversaccio/snekmate) | ||
|
||
## Disclaimer | ||
|
||
*These smart contracts and testing suite are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of anything provided herein or through related user interfaces. This repository and related code have not been audited and as such there can be no assurance anything will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.* | ||
|
||
## License | ||
|
||
See [LICENSE](./LICENSE) for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
[profile.default] | ||
solc = "0.8.19" | ||
solc_version = "0.8.28" | ||
evm_version = "cancun" | ||
|
||
optimizer = true | ||
optimizer_runs = 9_999_999 | ||
|
||
# Configure remappings | ||
remappings = [ | ||
"@std=lib/forge-std/src/", | ||
"@solbase=lib/solbase/" | ||
"@solady=lib/solady/", | ||
"@forge=lib/forge-std/src/" | ||
] | ||
|
||
[profile.intense.fuzz] | ||
runs = 5_000 | ||
[profile.via-ir] | ||
via_ir = true | ||
|
||
[fmt] | ||
line_length = 100 |
Submodule forge-std
deleted from
8b092b
Submodule solbase
deleted from
e12d00
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
/// @notice Standard contract ownership. | ||
/// @author Zolidity (https://github.com/z0r0z/zolidity/blob/main/src/ERC173.sol) | ||
abstract contract ERC173 { | ||
event OwnershipTransferred(address indexed from, address indexed to); | ||
|
||
error Unauthorized(); | ||
|
||
address public owner; | ||
|
||
modifier onlyOwner() virtual { | ||
require(msg.sender == owner, Unauthorized()); | ||
_; | ||
} | ||
|
||
function _setOwner(address to) internal virtual { | ||
emit OwnershipTransferred(msg.sender, owner = to); | ||
} | ||
|
||
function transferOwnership(address to) public virtual onlyOwner { | ||
_setOwner(to); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
/// @notice Standard fungible token. | ||
/// @author Zolidity (https://github.com/z0r0z/zolidity/blob/main/src/ERC20.sol) | ||
abstract contract ERC20 { | ||
event Approval(address indexed from, address indexed to, uint256 amount); | ||
event Transfer(address indexed from, address indexed to, uint256 amount); | ||
|
||
string public name; | ||
string public symbol; | ||
uint256 public constant decimals = 18; | ||
|
||
uint256 public totalSupply; | ||
|
||
mapping(address holder => uint256) public balanceOf; | ||
mapping(address holder => mapping(address spender => uint256)) public allowance; | ||
|
||
constructor(string memory _name, string memory _symbol) payable { | ||
(name, symbol) = (_name, _symbol); | ||
} | ||
|
||
function approve(address to, uint256 amount) public virtual returns (bool) { | ||
allowance[msg.sender][to] = amount; | ||
emit Approval(msg.sender, to, amount); | ||
return true; | ||
} | ||
|
||
function transfer(address to, uint256 amount) public virtual returns (bool) { | ||
return transferFrom(msg.sender, to, amount); | ||
} | ||
|
||
function transferFrom(address from, address to, uint256 amount) public virtual returns (bool) { | ||
if (from != msg.sender) { | ||
if (allowance[from][msg.sender] != type(uint256).max) { | ||
allowance[from][msg.sender] -= amount; | ||
} | ||
} | ||
balanceOf[from] -= amount; | ||
unchecked { | ||
balanceOf[to] += amount; | ||
} | ||
emit Transfer(from, to, amount); | ||
return true; | ||
} | ||
|
||
function _mint(address to, uint256 amount) internal virtual { | ||
totalSupply += amount; | ||
unchecked { | ||
balanceOf[to] += amount; | ||
} | ||
emit Transfer(address(0), to, amount); | ||
} | ||
|
||
function _burn(address from, uint256 amount) internal virtual { | ||
balanceOf[from] -= amount; | ||
unchecked { | ||
totalSupply -= amount; | ||
} | ||
emit Transfer(from, address(0), amount); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
/// @notice Reentrant call guard. | ||
/// @author Zolidity (https://github.com/z0r0z/zolidity/blob/main/src/ReentrancyGuard.sol) | ||
abstract contract ReentrancyGuard { | ||
error Reentrancy(); | ||
|
||
uint256 internal _guard = 1; | ||
|
||
modifier nonReentrant() virtual { | ||
_setReentrancyGuard(); | ||
_; | ||
_clearReentrancyGuard(); | ||
} | ||
|
||
function _setReentrancyGuard() internal virtual { | ||
require(_guard != 2, Reentrancy()); | ||
_guard = 2; | ||
} | ||
|
||
function _clearReentrancyGuard() internal virtual { | ||
_guard = 1; | ||
} | ||
} |
Oops, something went wrong.