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

wrapper.js:10 Uncaught TypeError: Cannot use 'in' operator to search for '_solidity_version' in undefined #657

Open
xx014939 opened this issue Sep 9, 2022 · 3 comments
Labels
waiting for more input Issues waiting for more input by the reporter

Comments

@xx014939
Copy link

xx014939 commented Sep 9, 2022

Description

Hey guys, I have been trying to use solc in a React.js app for around a week now, and I can't get it to work!

I am importing solc using the following statements

import * as wrapper from 'solc/wrapper';
const solc = wrapper(window.Module);

However, upon compiling I get the following error in the browser

wrapper.js:10 Uncaught TypeError: Cannot use 'in' operator to search for '_solidity_version' in undefined

I've tried a number of ways around this, but none seem to work
Has anyone else had a similar issue?
Thanks

@axic axic transferred this issue from ethereum/solidity Sep 11, 2022
@r0qs
Copy link
Member

r0qs commented Sep 12, 2022

Hi @xx014939, can you provide more details of your setup? What version of solc-js are you using?

Probably related to #627

@xx014939
Copy link
Author

Hi @xx014939, can you provide more details of your setup? What version of solc-js are you using?

Probably related to #627

Hey @r0qs

The package.json file of the node module contains the following properties

"name": "solc",
"version": "0.8.16",
"description": "Solidity compiler",
"main": "index.js",
"bin": {
"solcjs": "solc.js"
},

So I'm on version 0.8.16.

_solidity-version is only mentioned once in wrapper.js, on line 36 which reads as follows

let version;
if ('_solidity_version' in soljson) {
version = soljson.cwrap('solidity_version', 'string', []);
}
else {
version = soljson.cwrap('version', 'string', []);
}

Thanks

@r0qs
Copy link
Member

r0qs commented Sep 26, 2022

Hi @xx014939, in which browser are you testing? Chromium-based browsers seem to have a problem loading the wasm binary in the main thread. So you are currently required to use a web worker. You can see here: #627 (comment) an example of how to do it.

However, if you are using firefox, this should work:

...
<script type="text/javascript" src="https://binaries.soliditylang.org/bin/soljson-v0.8.16+commit.07a7930e.js"></script>
<script type="text/javascript" src="<path_to_where_your_bundle_is>/bundle.js"></script>
...
import wrapper from 'solc/wrapper';
...
const solc = wrapper(window.Module);
console.log(solc.version());

@cameel cameel added the waiting for more input Issues waiting for more input by the reporter label Feb 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting for more input Issues waiting for more input by the reporter
Projects
None yet
Development

No branches or pull requests

3 participants