Skip to content

Commit

Permalink
Merge branch 'main' into review-base
Browse files Browse the repository at this point in the history
  • Loading branch information
0age committed Nov 7, 2024
2 parents 971e1a0 + 5a9946c commit 11ab051
Show file tree
Hide file tree
Showing 62 changed files with 16,827 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: CI

on:
push:
pull_request:
workflow_dispatch:

env:
FOUNDRY_PROFILE: ci

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Show Forge version
run: |
forge --version
- name: Run Forge fmt
run: |
forge fmt --check
id: fmt

- name: Run Forge build
run: |
forge build --sizes
id: build

- name: Run Forge tests
run: |
forge test -vvv
id: test
env:
FORGE_SNAPSHOT_CHECK: true
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiler files
cache/
out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/

# Docs
docs/

# Dotenv file
.env
15 changes: 15 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/vectorized/solady
[submodule "lib/soledge"]
path = lib/soledge
url = https://github.com/vectorized/soledge
[submodule "lib/permit2"]
path = lib/permit2
url = https://github.com/Uniswap/permit2
[submodule "lib/tstorish"]
path = lib/tstorish
url = https://github.com/ProjectOpenSea/tstorish
736 changes: 736 additions & 0 deletions README.md

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[profile.default]
solc = '0.8.28'
evm_version='cancun'
via_ir = true
# optimizer_runs = 4_294_967_295
optimizer_runs = 200
bytecode_hash = 'none'
src = "src"
out = "out"
libs = ["lib"]
extra_output_files = ["irOptimized"]

[profile.default.optimizer_details.yulDetails]
# optimizerSteps = "dhfoD[xarrscLMcCTU]uljmul:fDnTOcmu"
# TODO: use default with everything but FunctionSpecializer (F)

[fmt]
line_length = 210
tab_width = 4
bracket_spacing = true
Binary file added images/TheCompact-Inheritance-Graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions lib/forge-std
Submodule forge-std added at 1de6ee
1 change: 1 addition & 0 deletions lib/permit2
Submodule permit2 added at cc56ad
1 change: 1 addition & 0 deletions lib/solady
Submodule solady added at e0ef35
1 change: 1 addition & 0 deletions lib/soledge
Submodule soledge added at 26dfa8
1 change: 1 addition & 0 deletions lib/tstorish
Submodule tstorish added at e0dd75
39 changes: 39 additions & 0 deletions script/TheCompact.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import { Script, console } from "forge-std/Script.sol";
import { TheCompact } from "../src/TheCompact.sol";

interface ImmutableCreate2Factory {
function safeCreate2(bytes32 salt, bytes calldata initializationCode) external payable returns (address deploymentAddress);
}

contract TheCompactScript is Script {
TheCompact public theCompact;

function setUp() public { }

function run() public {
vm.startBroadcast();

// ensure permit2 is deployed
assert(address(0x000000000022D473030F116dDEE9F6B43aC78BA3).code.length > 0);

// to deploy using create2 (need to rederive salt and target address when changing code):
bytes32 salt = bytes32(0x00000000000000000000000000000000000000008a0f466a78cd1102ce3d82f7);
address targetAddress = address(0x00000000000018DF021Ff2467dF97ff846E09f48);
// ensure create2 deployer is deployed
address immutableCreate2Factory = address(0x0000000000FFe8B47B3e2130213B802212439497);
assert(immutableCreate2Factory.code.length > 0);
// deploy it and check the target address
theCompact = TheCompact(ImmutableCreate2Factory(immutableCreate2Factory).safeCreate2(salt, type(TheCompact).creationCode));
assert(address(theCompact) == targetAddress);

// // to just deploy it directly:
// theCompact = new TheCompact();

assert(keccak256(bytes(theCompact.name())) == keccak256(bytes("The Compact")));

vm.stopBroadcast();
}
}
42 changes: 42 additions & 0 deletions snapshots/TheCompactTest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"basicTransfer": "56867",
"basicWithdrawal": "59992",
"batchClaim": "112512",
"batchClaimRegisteredWithDeposit": "112512",
"batchClaimRegisteredWithDepositWithWitness": "113271",
"batchClaimWithWitness": "113265",
"batchDepositAndRegisterViaPermit2": "222059",
"batchDepositAndRegisterWithWitnessViaPermit2": "222037",
"batchTransfer": "81344",
"batchWithdrawal": "100093",
"claim": "56974",
"claimAndWithdraw": "73432",
"claimWithWitness": "59471",
"depositAndRegisterViaPermit2": "124429",
"depositBatchSingleERC20": "68050",
"depositBatchSingleNative": "28353",
"depositBatchViaPermit2NativeAndERC20": "129751",
"depositBatchViaPermit2SingleERC20": "104905",
"depositERC20AndURI": "67276",
"depositERC20Basic": "67302",
"depositERC20ViaPermit2AndURI": "98471",
"depositETHAndURI": "26754",
"depositETHBasic": "28391",
"qualifiedBatchClaim": "114134",
"qualifiedBatchClaimWithWitness": "113672",
"qualifiedClaim": "60406",
"qualifiedClaimWithWitness": "59098",
"qualifiedSplitBatchClaim": "141486",
"qualifiedSplitBatchClaimWithWitness": "141552",
"qualifiedSplitClaim": "86977",
"qualifiedSplitClaimWithWitness": "87452",
"register": "25379",
"splitBatchClaim": "140788",
"splitBatchClaimWithWitness": "140749",
"splitBatchTransfer": "110652",
"splitBatchWithdrawal": "140361",
"splitClaim": "86751",
"splitClaimWithWitness": "86232",
"splitTransfer": "82482",
"splitWithdrawal": "93770"
}
Loading

0 comments on commit 11ab051

Please sign in to comment.