Skip to content

deployments json #299

@gotnoshoeson

Description

@gotnoshoeson

🔄 Reproduction Steps

  1. Deploy smart contract with hardhat-polkadot
  2. Plugin writes json file to ./deployments//.json
  3. metadata.solc_metadata.sources.content is NOT included in the output

🤔 Expected Behavior

I expected to get the same file written as the typical solc compiler deployment situation. Here's an example:

{
  "compiler": {
    "version": "0.8.20+commit.a1b79de6"
  },
  "language": "Solidity",
  "output": {
    "abi": [
      {
        "inputs": [
          {
            "internalType": "address",
            "name": "_owner",
            "type": "address"
          }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "anonymous": false,
        "inputs": [
          {
            "indexed": true,
            "internalType": "address",
            "name": "greetingSetter",
            "type": "address"
          },
          {
            "indexed": false,
            "internalType": "string",
            "name": "newGreeting",
            "type": "string"
          },
          {
            "indexed": false,
            "internalType": "bool",
            "name": "premium",
            "type": "bool"
          },
          {
            "indexed": false,
            "internalType": "uint256",
            "name": "value",
            "type": "uint256"
          }
        ],
        "name": "GreetingChange",
        "type": "event"
      },
      {
        "inputs": [],
        "name": "greeting",
        "outputs": [
          {
            "internalType": "string",
            "name": "",
            "type": "string"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "owner",
        "outputs": [
          {
            "internalType": "address",
            "name": "",
            "type": "address"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "premium",
        "outputs": [
          {
            "internalType": "bool",
            "name": "",
            "type": "bool"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [
          {
            "internalType": "string",
            "name": "_newGreeting",
            "type": "string"
          }
        ],
        "name": "setGreeting",
        "outputs": [],
        "stateMutability": "payable",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "totalCounter",
        "outputs": [
          {
            "internalType": "uint256",
            "name": "",
            "type": "string"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [
          {
            "internalType": "address",
            "name": "",
            "type": "address"
          }
        ],
        "name": "userGreetingCounter",
        "outputs": [
          {
            "internalType": "uint256",
            "name": "",
            "type": "uint256"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      {
        "inputs": [],
        "name": "withdraw",
        "outputs": [],
        "stateMutability": "nonpayable",
        "type": "function"
      },
      {
        "stateMutability": "payable",
        "type": "receive"
      }
    ],
    "devdoc": {
      "author": "BuidlGuidl",
      "kind": "dev",
      "methods": {
        "setGreeting(string)": {
          "params": {
            "_newGreeting": "(string memory) - new greeting to save on the contract"
          }
        }
      },
      "version": 1
    },
    "userdoc": {
      "kind": "user",
      "methods": {
        "setGreeting(string)": {
          "notice": "Function that allows anyone to change the state variable \"greeting\" of the contract and increase the counters"
        },
        "withdraw()": {
          "notice": "Function that allows the owner to withdraw all the Ether in the contract The function can only be called by the owner of the contract as defined by the isOwner modifier"
        }
      },
      "notice": "A smart contract that allows changing a state variable of the contract and tracking the changes It also allows the owner to withdraw the Ether in the contract",
      "version": 1
    }
  },
  "settings": {
    "compilationTarget": {
      "contracts/YourContract.sol": "YourContract"
    },
    "evmVersion": "paris",
    "libraries": {},
    "metadata": {
      "bytecodeHash": "ipfs",
      "useLiteralContent": true
    },
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "remappings": []
  },
  "sources": {
    "contracts/YourContract.sol": {
      "content": "//SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n// Useful for debugging. Remove when deploying to a live network.\nimport \"hardhat/console.sol\";\n\n// Use openzeppelin to inherit battle-tested implementations (ERC20, ERC721, etc)\n// import \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * A smart contract that allows changing a state variable of the contract and tracking the changes\n * It also allows the owner to withdraw the Ether in the contract\n * @author BuidlGuidl\n */\ncontract YourContract {\n    // State Variables\n    address public immutable owner;\n    string public greeting = \"Building Unstoppable Apps!!!\";\n    bool public premium = false;\n    uint256 public totalCounter = 0;\n    mapping(address => uint) public userGreetingCounter;\n\n    // Events: a way to emit log statements from smart contract that can be listened to by external parties\n    event GreetingChange(address indexed greetingSetter, string newGreeting, bool premium, uint256 value);\n\n    // Constructor: Called once on contract deployment\n    // Check packages/hardhat/deploy/00_deploy_your_contract.ts\n    constructor(address _owner) {\n        owner = _owner;\n    }\n\n    // Modifier: used to define a set of rules that must be met before or after a function is executed\n    // Check the withdraw() function\n    modifier isOwner() {\n        // msg.sender: predefined variable that represents address of the account that called the current function\n        require(msg.sender == owner, \"Not the Owner\");\n        _;\n    }\n\n    /**\n     * Function that allows anyone to change the state variable \"greeting\" of the contract and increase the counters\n     *\n     * @param _newGreeting (string memory) - new greeting to save on the contract\n     */\n    function setGreeting(string memory _newGreeting) public payable {\n        // Print data to the hardhat chain console. Remove when deploying to a live network.\n        console.log(\"Setting new greeting '%s' from %s\", _newGreeting, msg.sender);\n\n        // Change state variables\n        greeting = _newGreeting;\n        totalCounter += 1;\n        userGreetingCounter[msg.sender] += 1;\n\n        // msg.value: built-in global variable that represents the amount of ether sent with the transaction\n        if (msg.value > 0) {\n            premium = true;\n        } else {\n            premium = false;\n        }\n\n        // emit: keyword used to trigger an event\n        emit GreetingChange(msg.sender, _newGreeting, msg.value > 0, msg.value);\n    }\n\n    /**\n     * Function that allows the owner to withdraw all the Ether in the contract\n     * The function can only be called by the owner of the contract as defined by the isOwner modifier\n     */\n    function withdraw() public isOwner {\n        (bool success, ) = owner.call{ value: address(this).balance }(\"\");\n        require(success, \"Failed to send Ether\");\n    }\n\n    /**\n     * Function that allows the contract to receive ETH\n     */\n    receive() external payable {}\n}\n",
      "keccak256": "0x44f48bfee56e7310638990133d79a121f5ccce58f825790033879a297bd09d62",
      "license": "MIT"
    },
    "hardhat/console.sol": {
      "content": "[The entire hardhat console.sol content - thousands of lines of console logging functions]",
      "keccak256": "0x7434453e6d3b7d0e5d0eb7846ffdbc27f0ccf3b163591263739b628074dc103a",
      "license": "MIT"
    }
  },
  "version": 1
}

😯 Current Behavior

Here is the output using hardhat-polkadot and resolc. Notice the missing "content" section in the "sources" section of the data set:

{
  "compiler": {
    "version": "0.8.28+commit.7893614a"
  },
  "language": "Solidity",
  "output": {
    "abi": [
      {
        "inputs": [
          {
            "internalType": "address",
            "name": "_owner",
            "type": "address"
          }
        ],
        "stateMutability": "nonpayable",
        "type": "constructor"
      },
      {
        "anonymous": false,
        "inputs": [
          {
            "indexed": true,
            "internalType": "address",
            "name": "greetingSetter",
            "type": "address"
          },
          {
            "indexed": false,
            "internalType": "string",
            "name": "newGreeting",
            "type": "string"
          },
          {
            "indexed": false,
            "internalType": "bool",
            "name": "premium",
            "type": "bool"
          },
          {
            "indexed": false,
            "internalType": "uint256",
            "name": "value",
            "type": "uint256"
          }
        ],
        "name": "GreetingChange",
        "type": "event"
      },
      // ... rest of ABI functions
    ],
    "devdoc": {
      "author": "BuidlGuidl",
      "kind": "dev",
      "methods": {
        "setGreeting(string)": {
          "params": {
            "_newGreeting": "(string memory) - new greeting to save on the contract"
          }
        }
      },
      "version": 1
    },
    "userdoc": {
      // ... user documentation
    }
  },
  "settings": {
    "compilationTarget": {
      "contracts/YourContract.sol": "YourContract"
    },
    "evmVersion": "cancun",
    "libraries": {},
    "metadata": {
      "bytecodeHash": "ipfs"
    },
    "optimizer": {
      "details": {
        "constantOptimizer": false,
        "cse": false,
        // ... other optimizer settings
      },
      "runs": 200
    },
    "remappings": []
  },
  "sources": {
    "contracts/YourContract.sol": {
      "keccak256": "0x1e50769a2fab3dedab27b2f2a6319ec88720c1857a10b5ac5284cf327cf987fb",
      "license": "MIT",
      "urls": [
        "bzz-raw://17b3e1cddd01fbddac1645849606c5a10ccf9bf5f659dbd787f498d66576d342",
        "dweb:/ipfs/Qmc6RxKQi3Co3PWmCmZ9VWWPHos4r3x1h7sYr46UaezP8j"
      ]
    }
  },
  "version": 1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions