Skip to content

Commit

Permalink
Log solc compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dafaqdhruv committed Apr 4, 2023
1 parent adf505d commit 6a52bca
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion packages/codegen/src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,20 @@ export async function generateArtifacts (contractContent: string, contractFileNa
};

const solcInstance = (solcVersion === undefined) ? solc : await getSolcByVersion(solcVersion);
const compiledContract = JSON.parse(solcInstance.compile(JSON.stringify(input)));

if (compiledContract.errors?.length) {
compiledContract.errors.forEach((error: any) => {
if (error.severity === 'error') {
throw new Error(error.formattedMessage);
}

console.log(`${error.severity}: ${error.formattedMessage}`);
});
}

// Get artifacts for the required contract.
return JSON.parse(solcInstance.compile(JSON.stringify(input))).contracts[contractFileName][contractName];
return compiledContract.contracts[contractFileName][contractName];
}

async function getSolcByVersion (solcVersion: string): Promise<Solc> {
Expand Down
2 changes: 1 addition & 1 deletion packages/codegen/src/generate-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const main = async (): Promise<void> => {
type: 'string'
})
.option('continue-on-error', {
alias: 'C',
alias: 'e',
demandOption: false,
default: false,
describe: 'Continue generating watcher if unhandled types encountered',
Expand Down

0 comments on commit 6a52bca

Please sign in to comment.