Skip to content

Commit

Permalink
add additional compiler profiles to template
Browse files Browse the repository at this point in the history
  • Loading branch information
gretzke committed Nov 22, 2024
1 parent 0864bd3 commit dcaadef
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/Increment counter number.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26304
26263
2 changes: 1 addition & 1 deletion .forge-snapshots/Set counter number.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26394
26337
4 changes: 2 additions & 2 deletions docs/autogen/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Summary
- [Home](README.md)
# src
- [interface](src/interface/README.md)
- [ICounter](src/interface/ICounter.sol/interface.ICounter.md)
- [interfaces](src/interfaces/README.md)
- [ICounter](src/interfaces/ICounter.sol/interface.ICounter.md)
- [Counter](src/Counter.sol/contract.Counter.md)
4 changes: 2 additions & 2 deletions docs/autogen/src/src/Counter.sol/contract.Counter.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Counter
[Git Source](https://github.com/Uniswap/foundry-template/blob/6ed2d53f10b4739f84426a12bef01482d7a2e669/src/Counter.sol)
[Git Source](https://github.com/Uniswap/foundry-template/blob/0864bd3fda3ae2b97362ae80691cd59ca9cf5090/src/Counter.sol)

**Inherits:**
[ICounter](/src/interface/ICounter.sol/interface.ICounter.md)
[ICounter](/src/interfaces/ICounter.sol/interface.ICounter.md)


## State Variables
Expand Down
2 changes: 1 addition & 1 deletion docs/autogen/src/src/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@


# Contents
- [interface](/src/interface)
- [interfaces](/src/interfaces)
- [Counter](Counter.sol/contract.Counter.md)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ICounter
[Git Source](https://github.com/Uniswap/foundry-template/blob/6ed2d53f10b4739f84426a12bef01482d7a2e669/src/interface/ICounter.sol)
[Git Source](https://github.com/Uniswap/foundry-template/blob/0864bd3fda3ae2b97362ae80691cd59ca9cf5090/src/interfaces/ICounter.sol)


## Functions
Expand Down
File renamed without changes.
10 changes: 9 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ out = "out"
libs = ["lib"]
optimizer = true
optimizer_runs = 999999
via_ir = false
via_ir = true
solc = "0.8.26"
verbosity = 2
ffi = true
Expand All @@ -19,6 +19,14 @@ remappings = [
"@openzeppelin/contracts-upgradeable=lib/openzeppelin-contracts-upgradeable/contracts"
]

additional_compiler_profiles = [
{ name = "test", via_ir = false }
]

compilation_restrictions = [
{ paths = "test/**", via_ir = false }
]

[profile.default.fuzz]
runs = 1000

Expand Down
9 changes: 6 additions & 3 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ pragma solidity 0.8.26;

import 'forge-std/Script.sol';

import {Counter} from 'src/Counter.sol';
import {ICounter} from '../src/interfaces/ICounter.sol';

contract Deploy is Script {
using stdJson for string;

function run() public returns (Counter) {
function run() public returns (ICounter counter) {
uint256 initialNumber = 5;
return new Counter(initialNumber);
bytes memory bytecode = abi.encodePacked(vm.getCode('Counter.sol:Counter'), abi.encode(initialNumber));
assembly {
counter := create(0, add(bytecode, 0x20), mload(bytecode))
}
}
}
2 changes: 1 addition & 1 deletion src/Counter.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.26;

import {ICounter} from './interface/ICounter.sol';
import {ICounter} from './interfaces/ICounter.sol';

contract Counter is ICounter {
uint256 public number;
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions test/Counter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ pragma solidity 0.8.26;
import {GasSnapshot} from 'forge-gas-snapshot/GasSnapshot.sol';
import 'forge-std/Test.sol';

import {CounterDeployer, ICounter} from './deployers/CounterDeployer.sol';
import {Deploy} from 'script/Deploy.s.sol';
import {Counter} from 'src/Counter.sol';

abstract contract Deployed is Test {
Counter counter;
abstract contract Deployed is CounterDeployer {
ICounter counter;

function setUp() public virtual {
uint256 initialNumber = 10;
counter = new Counter(initialNumber);
counter = deploy(initialNumber);
}
}

Expand Down Expand Up @@ -40,7 +40,7 @@ contract CounterTest_Deployed is Deployed, GasSnapshot {
}

contract DeploymentTest is Test {
Counter counter;
ICounter counter;

function setUp() public virtual {
counter = new Deploy().run();
Expand Down
14 changes: 14 additions & 0 deletions test/deployers/CounterDeployer.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

import {ICounter} from '../../src/interfaces/ICounter.sol';
import {Test} from 'forge-std/Test.sol';

contract CounterDeployer is Test {
function deploy(uint256 initialNumber) internal returns (ICounter counter) {
bytes memory bytecode = abi.encodePacked(vm.getCode('Counter.sol:Counter'), abi.encode(initialNumber));
assembly {
counter := create(0, add(bytecode, 0x20), mload(bytecode))
}
}
}

0 comments on commit dcaadef

Please sign in to comment.