Comments (10)
Not discouraged yet. :)
from solc-js.
You do get the missing import statements returned by solc. There's a callback when a missing import reference is found.
from solc-js.
@axic Can you elaborate? It doesn't seem like this is in any of the documentation.
from solc-js.
It is not documented yet as it is not fully working.
You can pass a callback method to compile(input, optimise, callback)
, where the callback takes the import path as a parameter and returns the source code as a string. Processing the returned string in the C++ part sometimes doesn't work well.
At least getting the missing imports work reliably and that is how browser-solidity does it: it builds a list of missing imports by re-running the compiler. It might take a few iterations so it is only a workaround in that way. See https://github.com/chriseth/browser-solidity/blob/gh-pages/assets/js/app.js#L626.
(Here was the original issue for it: chriseth/browser-solidity#84. Might have some useful details.)
from solc-js.
@tcoulter I do think having an alternate implementation of the Solidity syntax in PEG is very useful and shouldn't be abandoned. Is your implementation supporting all language constructs or only import statements?
I was toying with the idea while back to have a try at an alternative compiler for the Solidity syntax, this might be a good starting point. At this stage it isn't a sane project to do though, but might make sense down the line in a couple of years.
from solc-js.
@axic It aims to support all language constructs, and it supports many of them (i.e., it at least parses everything in https://github.com/ConsenSys/solidity-parser/blob/master/test/doc_examples.sol). There's still work to be done to make the AST less verbose and more useful when these constructs are parsed, however.
Regarding the alternate compiler: Awesome, glad I could help!
from solc-js.
@tcoulter I don't think I will be able to allocate any time to that idea in the forseeable future. Trying to encourage you not to drop your PEG parser in case someone comes along writing a new compiler 😃
from solc-js.
@tcoulter fixed the import callback, see #7
from solc-js.
This is now possible using compileStandard()
.
from solc-js.
Hey @axic, any chance you can post an example? This input doesn't seem to work:
pragma solidity ^0.14.15;
import "./Dependency.sol";
contract MyContract {
}
var solcStandardInput = {
language: "Solidity",
sources: {
"Contract.sol": {
content: body // contract code
}
},
settings: {
outputSelection: {
"*": {
"*": [
"ast",
]
},
}
}
};
var output = solc.compileStandard(JSON.stringify(solcStandardInput));
The output is:
{ contracts: {},
errors:
[ { component: 'general',
formattedMessage: 'Contract.sol:3:1: ParserError: Source "Dependency.sol" not found: File import callback not supported\nimport "./Dependency.sol";\n^------------------------^\n',
message: 'Source "Dependency.sol" not found: File import callback not supported',
severity: 'error',
type: 'ParserError' } ],
sources: {} }
from solc-js.
Related Issues (20)
- Downloading binaries from `emscripten-asmjs/` and `emscripten-wasm/` dirs in solc-bin
- Switch to audited and fast version of sha3/keccak HOT 4
- Exception in an import callback leaves the compiler in an inconsistent state, leading to `You shall not have another CompilerStack aside me` error on next compilation HOT 13
- Does solc.loadRemoteVersion() download a new version of solc each time it is run? HOT 2
- Different bytecode when compiling from both solc-js and remix IDE
- cannot uninstall HOT 2
- OSError: [Errno 86] Bad CPU type in executable: HOT 1
- Cannot remap openzeppelin to use when I compile with solc HOT 1
- Release types on npm HOT 3
- Handle standard JSON transalation with `outputSelection` for `=<0.4.19`
- Failed to compile large json inputs HOT 1
- Callback not supported... HOT 2
- Identifier already declared HOT 2
- solc-select is out of date. Please run `solc-select upgrade` HOT 1
- Support for `--metadata` flag HOT 4
- 0.8.23 npm release won't install on Windows due to a stray dependency HOT 3
- findImports fallback on webWorkers not working HOT 5
- loadRemoteVersion is not working with jest test HOT 3
- 'Expected Pragma' error in solc but same code compiles in remix HOT 1
- Improvement: `content` not a key in solidity `input description` in solidity official doc (except under `destructible`) .
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from solc-js.