Skip to content

Commit

Permalink
Check warnings when loading artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lbqds committed May 27, 2024
1 parent 8eb319e commit d29c64b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/web3/src/contract/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -696,12 +696,14 @@ export class Project {
const contracts = new Map<string, Compiled<Contract>>()
const scripts = new Map<string, Compiled<Script>>()
const structs = await Project.loadStructs(artifactsRootDir)
const allWarnings: string[] = []
for (const sourceInfo of sourceInfos) {
const info = projectArtifact.infos.get(sourceInfo.name)
if (typeof info === 'undefined') {
throw Error(`Unable to find project info for ${sourceInfo.name}, please rebuild the project`)
}
const warnings = info.warnings
allWarnings.push(...warnings)
const artifactDir = sourceInfo.getArtifactPath(artifactsRootDir)
if (sourceInfo.type === SourceKind.Contract) {
const artifact = await Contract.fromArtifactFile(
Expand All @@ -716,16 +718,11 @@ export class Project {
scripts.set(artifact.name, new Compiled(sourceInfo, artifact, warnings))
}
}
if (errorOnWarnings) {
Project.checkCompilerWarnings(allWarnings, errorOnWarnings)
}

return new Project(
contractsRootDir,
artifactsRootDir,
sourceInfos,
contracts,
scripts,
structs,
projectArtifact
)
return new Project(contractsRootDir, artifactsRootDir, sourceInfos, contracts, scripts, structs, projectArtifact)
} catch (error) {
console.log(`Failed to load artifacts, error: ${error}, try to re-compile contracts...`)
return Project.compile(
Expand Down

0 comments on commit d29c64b

Please sign in to comment.