Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
z0r0z authored Feb 1, 2024
0 parents commit f5c4d88
Show file tree
Hide file tree
Showing 12 changed files with 835 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu.
{
"name": "Ubuntu",
// Or, use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile.
"image": "mcr.microsoft.com/devcontainers/base:jammy",
"features": {
"ghcr.io/devcontainers/features/rust:1": {
"version": "latest",
"profile": "default"
}
},
"customizations": {
"vscode": {
"extensions": [
"JuanBlanco.solidity"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "curl -L https://foundry.paradigm.xyz | bash && source /home/vscode/.bashrc && foundryup"

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 2 additions & 0 deletions .gas-snapshot
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Tester:test(string) (runs: 256, μ: 47361, ~: 24565)
TesterTest:testTest() (gas: 27613)
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci

on: [push]

jobs:
tests:
name: Forge Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: dependencies
run: forge install
- name: tests
run: forge test

snapshot:
name: Forge Snapshot
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: dependencies
run: forge install
- name: check contract sizes
run: forge build --sizes
- name: check gas snapshots
run: forge snapshot --check
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
cache
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# [zenplate](https://github.com/z0r0z/zenplate) [![License: AGPL-3.0-only](https://img.shields.io/badge/License-AGPL-black.svg)](https://opensource.org/license/agpl-v3/) [![solidity](https://img.shields.io/badge/solidity-%5E0.8.19-black)](https://docs.soliditylang.org/en/v0.8.19/) [![Foundry](https://img.shields.io/badge/Built%20with-Foundry-000000.svg)](https://getfoundry.sh/) ![tests](https://github.com/z0r0z/zenplate/actions/workflows/ci.yml/badge.svg)

Simpler foundry template.

## Getting Started

Click [`use this template`](https://github.com/z0r0z/zenplate/generate) to start.

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
scripts
├─ Deploy.s.sol — Test Deployment
src
├─ Tester — Tester Contract
test
└─ Tester.t - Test Contract
```

## Notable Mentions

- [femplate](https://github.com/refcell/femplate)
- [prb-foundry-template](https://github.dev/PaulRBerg/foundry-template)

## 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.
19 changes: 19 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[profile.default]
solc_version = "0.8.24"
evm_version = "shanghai"

optimizer = true
optimizer_runs = 9_999_999

[profile.via-ir]
via_ir = true

[fmt]
line_length = 100

[rpc_endpoints]
main = "https://rpc.ankr.com/eth"
base = "https://rpc.ankr.com/base"
poly = "https://rpc.ankr.com/polygon"
opti = "https://rpc.ankr.com/optimism"
arbi = "https://rpc.ankr.com/arbitrum"
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 4513bc
1 change: 1 addition & 0 deletions lib/solady
Submodule solady added at 8919f6
14 changes: 14 additions & 0 deletions src/Tester.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

contract Tester {
event Tested(string _data);

string public data;

function test(string calldata _data) public payable {
data = _data;

emit Tested(_data);
}
}
21 changes: 21 additions & 0 deletions test/Tester.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity ^0.8.19;

import {Tester} from "../src/Tester.sol";
import {Test} from "../lib/forge-std/src/Test.sol";

contract TesterTest is Test {
Tester immutable tester = new Tester();

function setUp() public payable {
// vm.createSelectFork(vm.rpcUrl('main')); // Ethereum mainnet fork.
// vm.createSelectFork(vm.rpcUrl('base')); // Base OptimismL2 fork.
// vm.createSelectFork(vm.rpcUrl('poly')); // Polygon network fork.
// vm.createSelectFork(vm.rpcUrl('opti')); // Optimism EthL2 fork.
// vm.createSelectFork(vm.rpcUrl('arbi')); // Arbitrum EthL2 fork.
}

function testTest() public payable {
tester.test("ommm");
}
}

0 comments on commit f5c4d88

Please sign in to comment.