Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- name: Run coverage
run: |
forge coverage --report summary --report lcov
forge coverage --ir-minimum --allow-failure --report summary --report lcov
ls -la lcov.info || echo "lcov.info not found"

- name: Generate coverage report
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/gas-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,13 @@ jobs:

- name: Generate gas snapshot for base
run: |
forge snapshot --snap .gas-snapshot-base
# Copy base snapshot to temp location so it survives checkout
cp .gas-snapshot-base /tmp/gas-snapshot-base
forge snapshot --snap .gas-snapshot-base || echo "::warning::Base branch snapshot failed (base may have compilation errors)"
# Copy base snapshot to temp location if it exists, create empty one if base was broken
if [ -f .gas-snapshot-base ]; then
cp .gas-snapshot-base /tmp/gas-snapshot-base
else
touch /tmp/gas-snapshot-base
fi

- name: Checkout PR branch again
uses: actions/checkout@v4
Expand Down
5 changes: 0 additions & 5 deletions script/ERC20.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ pragma solidity ^0.8.13;
*/

import {Script} from "forge-std/Script.sol";
import {ERC20Facet} from "../src/token/ERC20/ERC20/ERC20Facet.sol";

contract CounterScript is Script {
ERC20Facet public erc20;

function setUp() public {}

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

erc20 = new ERC20Facet();

vm.stopBroadcast();
}
}
4 changes: 2 additions & 2 deletions test/harnesses/token/ERC20/ERC20/ERC20BurnFacetHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ contract ERC20BurnFacetHarness is ERC20BurnFacet {
*/
function approve(address _spender, uint256 _value) external returns (bool) {
require(_spender != address(0), "ERC20: approve to zero address");
ERC20Storage storage s = getStorage();
ERC20TransferStorage storage s = getStorage();
s.allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
Expand All @@ -45,7 +45,7 @@ contract ERC20BurnFacetHarness is ERC20BurnFacet {
* @dev Only used for testing - exposes internal mint functionality
*/
function mint(address _to, uint256 _value) external {
ERC20Storage storage s = getStorage();
ERC20TransferStorage storage s = getStorage();
require(_to != address(0), "ERC20: mint to zero address");
unchecked {
s.totalSupply += _value;
Expand Down
41 changes: 0 additions & 41 deletions test/harnesses/token/ERC20/ERC20/ERC20FacetHarness.sol

This file was deleted.

26 changes: 0 additions & 26 deletions test/harnesses/token/ERC20/ERC20/ERC20Harness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ import "src/token/ERC20/ERC20/ERC20Mod.sol" as ERC20Mod;
* @dev Required for testing since LibERC20 only has internal functions
*/
contract ERC20Harness {
/**
* @notice Initialize the ERC20 token storage
* @dev Only used for testing
*/
function initialize(string memory _name, string memory _symbol, uint8 _decimals) external {
ERC20Mod.ERC20Storage storage s = ERC20Mod.getStorage();
s.name = _name;
s.symbol = _symbol;
s.decimals = _decimals;
}

/**
* @notice Exposes ERC20Mod.mint as an external function
*/
Expand Down Expand Up @@ -59,21 +48,6 @@ contract ERC20Harness {
ERC20Mod.approve(_spender, _value);
}

/**
* @notice Get storage values for testing
*/
function name() external view returns (string memory) {
return ERC20Mod.getStorage().name;
}

function symbol() external view returns (string memory) {
return ERC20Mod.getStorage().symbol;
}

function decimals() external view returns (uint8) {
return ERC20Mod.getStorage().decimals;
}

function totalSupply() external view returns (uint256) {
return ERC20Mod.getStorage().totalSupply;
}
Expand Down
25 changes: 25 additions & 0 deletions test/harnesses/token/ERC20/ERC20/ERC20MetadataFacetHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.30;

/* Compose
* https://compose.diamonds
*/

import {ERC20MetadataFacet} from "src/token/ERC20/ERC20/ERC20MetadataFacet.sol";

/**
* @title ERC20MetadataFacetHarness
* @notice Test harness for ERC20MetadataFacet that adds initialization for testing
*/
contract ERC20MetadataFacetHarness is ERC20MetadataFacet {
/**
* @notice Initialize the ERC20 metadata storage
* @dev Only used for testing - production diamonds should initialize in constructor
*/
function initialize(string memory _name, string memory _symbol, uint8 _decimals) external {
ERC20MetadataStorage storage s = getStorage();
s.name = _name;
s.symbol = _symbol;
s.decimals = _decimals;
}
}
14 changes: 7 additions & 7 deletions test/harnesses/token/ERC20/ERC20/ERC20PermitFacetHarness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract ERC20PermitFacetHarness is ERC20PermitFacet {
* @dev Only used for testing - production diamonds should initialize in constructor
*/
function initialize(string memory _name) external {
ERC20Storage storage s = getERC20Storage();
ERC20MetadataStorage storage s = getERC20MetadataStorage();
s.name = _name;
}

Expand All @@ -28,7 +28,7 @@ contract ERC20PermitFacetHarness is ERC20PermitFacet {
* @dev Only used for testing - exposes internal mint functionality
*/
function mint(address _to, uint256 _value) external {
ERC20Storage storage s = getERC20Storage();
ERC20TransferStorage storage s = getERC20TransferStorage();
require(_to != address(0), "ERC20: mint to zero address");
unchecked {
s.totalSupply += _value;
Expand All @@ -41,23 +41,23 @@ contract ERC20PermitFacetHarness is ERC20PermitFacet {
* @notice ERC20 view helpers so tests can call the standard API
*/
function balanceOf(address _account) external view returns (uint256) {
return getERC20Storage().balanceOf[_account];
return getERC20TransferStorage().balanceOf[_account];
}

function totalSupply() external view returns (uint256) {
return getERC20Storage().totalSupply;
return getERC20TransferStorage().totalSupply;
}

function allowance(address _owner, address _spender) external view returns (uint256) {
return getERC20Storage().allowance[_owner][_spender];
return getERC20TransferStorage().allowance[_owner][_spender];
}

/**
* @notice Minimal approve implementation for tests
*/
function approve(address _spender, uint256 _value) external returns (bool) {
require(_spender != address(0), "ERC20: approve to zero address");
ERC20Storage storage s = getERC20Storage();
ERC20TransferStorage storage s = getERC20TransferStorage();
s.allowance[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
Expand All @@ -67,7 +67,7 @@ contract ERC20PermitFacetHarness is ERC20PermitFacet {
* @notice TransferFrom implementation for tests (needed by test_Permit_ThenTransferFrom)
*/
function transferFrom(address _from, address _to, uint256 _value) external returns (bool) {
ERC20Storage storage s = getERC20Storage();
ERC20TransferStorage storage s = getERC20TransferStorage();
require(_to != address(0), "ERC20: transfer to zero address");
require(s.balanceOf[_from] >= _value, "ERC20: insufficient balance");

Expand Down
30 changes: 30 additions & 0 deletions test/harnesses/token/ERC20/ERC20/ERC20TransferFacetHarness.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.30;

/* Compose
* https://compose.diamonds
*/

import {ERC20TransferFacet} from "src/token/ERC20/ERC20/ERC20TransferFacet.sol";

/**
* @title ERC20TransferFacetHarness
* @notice Test harness for ERC20TransferFacet that adds minting for testing
*/
contract ERC20TransferFacetHarness is ERC20TransferFacet {
/**
* @notice Mint tokens to an address
* @dev Only used for testing - exposes internal mint functionality
*/
function mint(address _to, uint256 _value) external {
ERC20TransferStorage storage s = getStorage();
if (_to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
unchecked {
s.totalSupply += _value;
s.balanceOf[_to] += _value;
}
emit Transfer(address(0), _to, _value);
}
}
Loading
Loading