Skip to content

Commit

Permalink
Fix contract conflict checking
Browse files Browse the repository at this point in the history
  • Loading branch information
chasefleming committed May 15, 2024
1 parent 9d33723 commit 06cd134
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions internal/dependencymanager/dependencyinstaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,25 +207,24 @@ func (di *DependencyInstaller) Add(depSource, customName string) error {
}

func (di *DependencyInstaller) addDependency(dep config.Dependency) error {
if _, exists := di.dependencies[dep.Source.Address.String()]; exists {
sourceString := fmt.Sprintf("%s://%s.%s", dep.Source.NetworkName, dep.Source.Address.String(), dep.Source.ContractName)

if _, exists := di.dependencies[sourceString]; exists {
return nil
}

di.dependencies[dep.Source.Address.String()] = dep
di.dependencies[sourceString] = dep

return nil

}

// checkForConflictingContracts checks if any of the dependencies conflict with contracts already in the state
func (di *DependencyInstaller) checkForConflictingContracts() {
for _, dependency := range di.dependencies {
_, err := di.initialContractsState.ByName(dependency.Name)
if err != nil {
if !isCoreContract(dependency.Name) {
msg := util.MessageWithEmojiPrefix("❌", fmt.Sprintf("Contract named %s already exists in flow.json", dependency.Name))
di.logs.issues = append(di.logs.issues, msg)
}
foundContract, _ := di.initialContractsState.ByName(dependency.Name)
if foundContract != nil {
msg := util.MessageWithEmojiPrefix("❌", fmt.Sprintf("Contract named %s already exists in flow.json", dependency.Name))
di.logs.issues = append(di.logs.issues, msg)
}
}
}
Expand Down

0 comments on commit 06cd134

Please sign in to comment.