Skip to content

Commit

Permalink
Make add by core contract case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
jribbink committed Sep 24, 2024
1 parent f99a061 commit aa185fd
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions internal/dependencymanager/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ package dependencymanager
import (
"fmt"

"github.com/onflow/flow-cli/internal/util"
"github.com/onflow/flow-go/fvm/systemcontracts"

"github.com/spf13/cobra"

"github.com/onflow/flowkit/v2"
"github.com/onflow/flowkit/v2/output"

flowGo "github.com/onflow/flow-go/model/flow"

"github.com/onflow/flow-cli/internal/command"
"github.com/onflow/flow-cli/internal/util"
)

type addFlagsCollection struct {
Expand Down Expand Up @@ -77,8 +80,9 @@ func add(
}

// First check if the dependency is a core contract.
if isCoreContract(dep) {
if err := installer.AddByCoreContractName(dep, addFlags.name); err != nil {
coreContractName := findCoreContractCaseInsensitive(dep)
if coreContractName != "" {
if err := installer.AddByCoreContractName(coreContractName, addFlags.name); err != nil {
logger.Error(fmt.Sprintf("Error: %v", err))
return nil, err
}
Expand All @@ -93,3 +97,12 @@ func add(

return nil, nil
}

func findCoreContractCaseInsensitive(name string) string {
for _, contract := range systemcontracts.SystemContractsForChain(flowGo.Mainnet).All() {
if name == contract.Name {
return contract.Name
}
}
return ""
}

0 comments on commit aa185fd

Please sign in to comment.