Skip to content

[Bug] Importing ERC721 file using sol! #956

Open
@Brianspha

Description

@Brianspha

Component

sol! macro

What version of Alloy are you on?

1.1.2

Operating System

macOS (Apple Silicon)

Describe the bug

I'm encountering an issue where the sol! macro fails to load a Solidity file implementing the standard OpenZeppelin ERC721 contract. The error indicates that the file does not exist, even though it is present at the specified path. Interestingly, when I replace ERC721.sol with ERC20.sol in the same directory, the sol! macro functions correctly. The file is a flattened ERC721 contract

#[rstest]
#[case("ERC721.sol", "0.8.20")]
fn test_erc721_transfer(
    #[case] contract: &str,
    #[case] version: &str,
    #[with(contract)] load_contract: PathBuf,
    #[with(version)] solc: Compiler,
) {
    sol!("tests/contracts/ERC721.sol");
    use NonFungibleToken::*;
    // Test logic here
}

contract content

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";

contract NonFungibleToken is ERC721 {
    constructor() ERC721("MyNFT", "MNFT") {}

    function balanceOf(address account) public view override returns (uint256) {
        return super.balanceOf(account);
    }

    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public override {
        super.safeTransferFrom(from, to, tokenId, "");
    }


    function mint(address who, uint256 tokenId) public {
        _mint(who, tokenId);
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions