Skip to content

Commit

Permalink
fix: semver natspec check failure
Browse files Browse the repository at this point in the history
  • Loading branch information
agusduha committed Oct 3, 2024
1 parent 1981789 commit c3cb7f6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 13 deletions.
13 changes: 11 additions & 2 deletions packages/contracts-bedrock/scripts/checks/semver-natspec/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func run() error {

artifactsDir := filepath.Join(cwd, "forge-artifacts")
srcDir := filepath.Join(cwd, "src")
testDir := filepath.Join(cwd, "test")

artifactFiles, err := glob(artifactsDir, ".json")
if err != nil {
Expand All @@ -72,6 +73,10 @@ func run() error {
if err != nil {
return fmt.Errorf("failed to get contract files: %w", err)
}
testFiles, err := glob(testDir, ".sol")
if err != nil {
return fmt.Errorf("failed to get test files: %w", err)
}

var hasErr int32
var outMtx sync.Mutex
Expand Down Expand Up @@ -129,8 +134,12 @@ func run() error {
return
}

contractPath := contractFiles[contractName]
if contractPath == "" {
var contractPath string
if path, ok := contractFiles[contractName]; ok {
contractPath = path
} else if path, ok := testFiles[contractName]; ok {
contractPath = path
} else {
fail("%s: Source file not found", contractName)
return
}
Expand Down
13 changes: 2 additions & 11 deletions packages/contracts-bedrock/test/L2/SuperchainERC20.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,7 @@ import { BeaconProxy } from "@openzeppelin/contracts-v5/proxy/beacon/BeaconProxy
// Target contract
import { SuperchainERC20, ISuperchainERC20Extension } from "src/L2/SuperchainERC20.sol";
import { ISuperchainERC20Errors } from "src/L2/interfaces/ISuperchainERC20.sol";

contract SuperchainERC20Implementation is SuperchainERC20 {
function name() public pure override returns (string memory) {
return "SuperchainERC20";
}

function symbol() public pure override returns (string memory) {
return "SCE";
}
}
import { SuperchainERC20ImplementationMock } from "test/mocks/SuperchainERC20ImplementationMock.sol";

/// @title SuperchainERC20Test
/// @notice Contract for testing the SuperchainERC20 contract.
Expand All @@ -40,7 +31,7 @@ contract SuperchainERC20Test is Test {

/// @notice Sets up the test suite.
function setUp() public {
superchainERC20 = new SuperchainERC20Implementation();
superchainERC20 = new SuperchainERC20ImplementationMock();
}

/// @notice Helper function to setup a mock and expect a call to it.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.25;

import { SuperchainERC20 } from "src/L2/SuperchainERC20.sol";

/// @title SuperchainERC20ImplementationMock
/// @notice Mock contract just to create tests over an implementation of the SuperchainERC20 abstract contract.
contract SuperchainERC20ImplementationMock is SuperchainERC20 {
/// @notice Semantic version.
/// @custom:semver 1.0.0-beta.1
string public constant override version = "1.0.0-beta.1";

function name() public pure override returns (string memory) {
return "SuperchainERC20";
}

function symbol() public pure override returns (string memory) {
return "SCE";
}
}

0 comments on commit c3cb7f6

Please sign in to comment.