sbip-sg / solc-json-parser

A Powerful AST Parser for Solidity
12 stars 1 forks source link

Support compilation with remapping #81

Closed cassc closed 10 months ago

cassc commented 1 year ago

Remapping allows using source code outside the standard json file. Example

{
    "sources": {
        "Filename.sol": {
            "content": "import \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\npragma solidity >=0.7 <0.9.0;\n\n/**\n * @title Storage\n * @dev Store & retrieve value in a variable\n * @custom:dev-run-script ./scripts/deploy_with_ethers.ts\n */\ncontract Storage {\n\n    uint256 number;\n\n    /**\n     * @dev Store value in variable\n     * @param num value to store\n     */\n    function store(uint256 num) public {\n        number = num;\n    }\n\n    /**\n     * @dev Return value \n     * @return value of 'number'\n     */\n    function retrieve() public view returns (uint256){\n        return number;\n    }\n}"
        }
    },
  "language": "Solidity",
  "settings": {
    "remappings": ["@openzeppelin=node_modules/@openzeppelin/", "@asldfas=none-exists"]
  }
}