Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

[sol-compiler] AST is not present in the output when requested #2746

Closed
LogvinovLeon opened this issue Jan 7, 2021 · 2 comments
Closed

[sol-compiler] AST is not present in the output when requested #2746

LogvinovLeon opened this issue Jan 7, 2021 · 2 comments

Comments

@LogvinovLeon
Copy link
Contributor

Expected Behavior

AST should be present in the artifacts when requested

Current Behavior

It's not there even though Solidity returns it. It does not make it's way to the artifacts file

Possible Solution

In the https://github.com/0xProject/0x-monorepo/blob/development/packages/sol-compiler/src/compiler.ts#L396
Change from:

            const { id } = compilerOutput.sources[sourceContractPath];
            allSources[sourceContractPath] = { id, content };
        }
        const usedSources = getSourcesWithDependencies(contractPath, allSources, importRemappings);

        const contractVersion: ContractVersionData = {
            compilerOutput: compiledContract,
            sourceTreeHashHex,
            sources: _.mapValues(usedSources, ({ id }) => ({ id })),

to

            const { id, ast } = compilerOutput.sources[sourceContractPath];
            allSources[sourceContractPath] = { id, ast, content };
        }
        const usedSources = getSourcesWithDependencies(contractPath, allSources, importRemappings);

        const contractVersion: ContractVersionData = {
            compilerOutput: compiledContract,
            sourceTreeHashHex,
            sources: usedSources,

Steps to Reproduce (for bugs)

Compile any contract and request AST in the output.

Context

Trying to get an AST of the contract using sol-compiler

Your Environment

Package Version

└─ @0x/sol-compiler@4.4.3

@LogvinovLeon
Copy link
Contributor Author

@merklejerk Could you please take a look when you have a moment? Should be a quick fix

@dorothy-zbornak
Copy link
Contributor

Good to see you're still around, Leo. This should be fixed in sol-compiler@4.5.0, which I just published.

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

No branches or pull requests

2 participants