Skip to content

Commit

Permalink
look at node module contracts properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Malcador committed Oct 22, 2020
1 parent 5b14333 commit 07e6c92
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion hardhat/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func (dp *DeploymentProvider) GetContracts(

for path, _ := range hardhatMeta.Sources {
if !strings.Contains(path, "@") {
sources[path] = false
continue
}
absPath := path
Expand Down Expand Up @@ -197,7 +198,23 @@ func (dp *DeploymentProvider) GetContracts(

source, err := ioutil.ReadFile(localPath)
if err != nil {
return nil, 0, errors.Wrap(err, "failed reading contract source file")
localPath = filepath.Join("node_modules", currentLocalPath)
doesNotExist := providers.CheckIfFileDoesNotExist(localPath)
if doesNotExist {
localPath = providers.GetGlobalPathForModule(currentLocalPath)
}

source, err := ioutil.ReadFile(localPath)
if err != nil {
return nil, 0, errors.Wrap(err, "failed reading contract source file")
}

contracts = append(contracts, providers.Contract{
Source: string(source),
SourcePath: currentLocalPath,
})

continue
}

contracts = append(contracts, providers.Contract{
Expand Down

0 comments on commit 07e6c92

Please sign in to comment.