solc-typed-ast icon indicating copy to clipboard operation
solc-typed-ast copied to clipboard

compileSourceString function not working for specifically formatted contracts

Open malachylokicode opened this issue 1 year ago • 0 comments

When I try to run compileSourceString(fileName, srcAsStr, compilerVersionArray), on the following contract:

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

contract CharleneSample is ERC20, Ownable {
    constructor() ERC20("Sample", "SPL") Ownable(msg.sender) {
        _mint(msg.sender, 1000000 * 10 ** decimals()); // Mint initial supply to contract creator
    }

    function mint(address to, uint256 amount) public onlyOwner {
        _mint(to, amount);
    }
}

I get the following error:

  response: 'Unable to compile: Compiler Errors: ==== 0.8.23 ====:\n' +
    ' TypeError: Wrong argument count for constructor call: 1 arguments given but expected 0\n' +
    ' --> contracts/CharleneSimple.sol:7:35:\n' +
    '  |\n' +
    '7 | contract CharleneSample is ERC20, Ownable(msg.sender) {\n' +
    '  |                                   ^^^^^^^^^^^^^^^^^^^\n' +
    '\n' +
    '\n',
  status: 400,
  options: undefined
}

It seems like solc-typed-ast for some reason doesn't recognize that Ownable takes in a constructor argument.

malachylokicode avatar Aug 10 '24 19:08 malachylokicode