Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 5 - Compiler stopped working / All preferences have disappeared #100

Closed
DorianDaSilva opened this issue Jun 2, 2022 · 5 comments
Closed

Comments

@DorianDaSilva
Copy link

I am getting the following errors after trying to run
node deploy.js with Ganache UI

Box on lower left of the screen when editing settings.json>>>
solc error: TypeError: solc.compileStandardWrapper is not a function

Terminal>>>

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

SimpleStorage.sol - line 2

pragma solidity ^0.8.14

SyntaxError: Source file requires different compiler version (current compiler is 0.4.17+commit.bdeb9e52.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.8.14;

NOTE: Compiler was working fine and version was set properly.

Compiler version must be fixed [compiler-fixed]

Everything was fine before trying to deploy to ganache

async function main() {
  const provider = new ethers.provider.JsonRpcProvider("HTTP://0.0.0.0:8545");
  const wallet = new ethers.Wallet(
    "c893......................6c9a13081",
    provider
  );

Now, all compiler settings have disappeared from preferences, only get the option to edit json file and settings.json edits are not working.

Can anyone tell me what the hell is going on and how to fix this, plz?

@daalmana
Copy link

daalmana commented Jun 2, 2022

Did you check if ganache is running on local host 8545 and not at 7545?
Maybe also change HTTP into http (no caps)

You can see the local host in the ganache app on the top!

@DorianDaSilva
Copy link
Author

DorianDaSilva commented Jun 2, 2022

@daalmana Yes, I have tested all of this. It still doesn't resolve the issue with the compiler.

This is the deploy.js code

const ethers = require("ethers");
const fs = require("fs-extra");

async function main() {
  const provider = new ethers.provider.JsonRpcProvider("HTTP://0.0.0.0:8545");
  const wallet = new ethers.Wallet(
    "c893d45f...................................................fdef96c9a13081",
    provider
  );
  const abi = fs.readFileSync("./SimpleStorage_sol_SimpleStorage.abi", "utf8");
  const binary = fs.readFileSync(
    "./SimpleStorage_sol_SimpleStorage.bin",
    "utf8"
  );
  const contractFactory = new ethers.ContractFactory(abi, binary, wallet);
  console.log("Deploying, please wait...");
  const contract = await contractFactory.deploy(); //STOP here! wait for contract to deploy
  console.log(contract);
}

main()
  .then(() => ProcessingInstruction.exit(0))
  .catch((error) => {
    console.error(error);
    ProcessingInstruction.exit(1);
  });

This is the error I am getting running this code:

ReferenceError: ProcessingInstruction is not defined

And this the same simple storage contract I had on remix

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

contract SimpleStorage {
    uint256 favoriteNumber;

    mapping(string => uint256) public nameToFavoriteNumber;

    struct People {
        uint256 favoriteNumber;
        string name;
    }

    People[] public people;

    function store(uint256 _favoriteNumber) public virtual {
        favoriteNumber = _favoriteNumber;
    }

    function retrieve() public view returns (uint256) {
        return favoriteNumber;
    }

    function addPerson(string memory _name, uint256 _favoriteNumber) public {
        people.push(People(_favoriteNumber, _name));
        nameToFavoriteNumber[_name] = _favoriteNumber;
    }
}

Do you know whta could be the issue? What package maybe causing the issue?

@DorianDaSilva
Copy link
Author

Maybe it's a bug in json settings?

{
    "editor.defaultFormatter": "NomicFoundation.hardhat-solidity",
    "workbench.colorTheme": "Abyss",
    "html.format.unformatted": "esbenp.prettier-vscode",
    "eslint.format.enable": true,
    "editor.formatOnSave": true,
    "[javascript]": {
        "editor.defaultFormatter": "esbenp.prettier-vscode"
    },
    "files.autoSave": "afterDelay",
    "solang.target": "ewasm",
}
{
  "dependencies": {
    "ethers": "^5.6.8",
    "fs-extra": "^10.1.0",
    "solc": "^0.8.14-fixed"
  },
  "scripts": {
    "compile": "yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol"
  }
}

@daalmana
Copy link

daalmana commented Jun 2, 2022

Look at your main function at the bottom! It's should be procces not processingInstructions

image

@DorianDaSilva
Copy link
Author

@daalmana Thank you for the info. I modified it but now it returns

TypeError: Cannot read properties of undefined (reading 'JsonRpcProvider')

When running node deploy.js, I am assuming it is related to Ganache UI (I always run into issues using Ganache UI)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants